shouldExcludeFile static method
Check if a file should be excluded based on exclusion patterns
Implementation
static bool shouldExcludeFile(
String fileName,
String filePath,
List<String> exclusions,
) {
for (final exclusion in exclusions) {
// Support both simple patterns and glob-like patterns
if (exclusion.contains('*')) {
final regex = RegExp(
exclusion
.replaceAll('.', '\\.')
.replaceAll('*', '.*')
.replaceAll('?', '.'),
caseSensitive: false,
);
if (regex.hasMatch(fileName) || regex.hasMatch(filePath)) {
return true;
}
} else {
// Simple string matching
if (fileName.contains(exclusion) || filePath.contains(exclusion)) {
return true;
}
}
}
return false;
}