call method

List<String> call({
  1. required List<String> filePaths,
  2. required List<String> fileNamesToExclude,
})

Removes filePaths of files with any name given in fileNamesToExclude.

Implementation

List<String> call({
  required List<String> filePaths,
  required List<String> fileNamesToExclude,
}) {
  final mutableFilePaths = List<String>.from(filePaths);

  final fileNamePatterns = fileNamesToExclude
      .map((pattern) => pattern.replaceAll('.', '\\.')) // Escape dots
      .map((pattern) => pattern.replaceAll('*', r'.*'))
      .map((pattern) => RegExp(pattern))
      .toList(growable: false);

  mutableFilePaths.removeWhere((filePath) => _containsFileName(
        file: File(filePath),
        patterns: fileNamePatterns,
      ));

  return mutableFilePaths;
}