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.
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/fooand 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_modulesin a subdirectory relative to the project directory. This causes all globs to recurse inside thenode_modulesdirectory.