matchFile method

PatternMatchingResult matchFile(
  1. String file, [
  2. String? root
])

Matches a single file path without accessing the file system.

file - The file path to match root - Optional root directory (defaults to current directory)

Implementation

PatternMatchingResult matchFile(String file, [String? root]) {
  final rootPath = root ?? p.current;
  final relativePath = p.relative(file, from: rootPath);

  // Check if the file matches any include patterns
  final includeMatches = _matchesIncludePatterns(relativePath);

  if (!includeMatches) {
    return PatternMatchingResult(const []);
  }

  // Check if the file is excluded
  if (_matchesExcludePatterns(relativePath)) {
    return PatternMatchingResult(const []);
  }

  return PatternMatchingResult([FilePatternMatch(relativePath)]);
}