Search code examples
javascriptnode.jsglob

Can I use glob to filter an existing list of file paths?


I'm using glob for some file searching operations in Node, and also using glob patterns for an "ignore" list.

But I also want to be able to use just the ignore list, to filter an existing list of files (in this case changed files from git). Is there a way to use the glob library just as a text filter, rather than needing to interact with the filesystem? I don't want to have two separate implementations of the pattern depending on use-case.


Solution

  • After looking through the code for Glob, looks like the answer is in minimatch which glob uses for comparing paths.