Skip to main content

resolve_glob_patterns

Function resolve_glob_patterns 

Source
pub fn resolve_glob_patterns(
    root: &Path,
    patterns: &[String],
    exclusions: &[String],
) -> Result<Vec<PathBuf>>
Expand description

Resolves glob patterns to find directories, handling exclusions.

§Arguments

  • root - The root directory to resolve patterns from.
  • patterns - List of glob patterns to match (e.g., “packages/*”).
  • exclusions - List of glob patterns to exclude (e.g., “packages/excluded”). Note: Patterns starting with “!” in the patterns list are also treated as exclusions.

§Returns

A sorted list of unique, absolute paths (rooted under root) that match the patterns and are not excluded.

§Errors

Returns an error if any glob pattern is invalid or if the filesystem cannot be read while resolving glob matches.

§Implementation Notes

This implementation uses walkdir for efficient traversal and prunes common heavy directories (node_modules, .git, target, dist) to improve performance