Skip to content

Globing optimization for excludes with complex glob patterns #2000

@cdmihai

Description

@cdmihai

The current file system walking code that collects files that match a glob accepts a set of exclude patterns so it can prune the FS search tree in one file walk. It has some optimizations to completely back out of a certain directory.

This optimization does not work for complex patterns like **/foo/**. When a FS walk goes into a directory like /a/b/foo, it should backtrack out because the **/foo/** exclude would match all files under /a/b/foo. Instead, the current code walks the entire subtree under /a/b/foo and uses expensive Regex matching to exclude every file in the subtree.

A common scenario where this hits is when npm enabled projects place their node_modules in a subdirectory relative to the project directory. This causes all globs to recurse inside the node_modules directory.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions