matchesIgnorePattern function

  1. @visibleForTesting
bool matchesIgnorePattern({
  1. required String relativePath,
  2. required String pattern,
})

Returns whether relativePath matches a single gitignore-style pattern.

Implementation

@visibleForTesting
bool matchesIgnorePattern({
  required String relativePath,
  required String pattern,
}) {
  final normalizedPath = normalizeIgnoreRelativePath(relativePath);
  final globPatterns = expandIgnorePattern(pattern);

  return globPatterns.any(
    (globPattern) =>
        Glob(globPattern, context: p.posix).matches(normalizedPath),
  );
}