我可以使用glob来过滤现有的文件路径列表吗?

时间:2022-09-01 23:30:01

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

我在Node中使用glob进行一些文件搜索操作,并使用glob模式作为“ignore”列表。

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.

但我也希望能够只使用忽略列表来过滤现有的文件列表(在这种情况下是从git更改的文件)。有没有办法将glob库用作文本过滤器,而不是需要与文件系统交互?我不希望根据用例有两个单独的模式实现。

1 个解决方案

#1


0  

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

在查看Glob的代码之后,看起来答案是在minimatch中,glob用它来比较路径。

#1


0  

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

在查看Glob的代码之后,看起来答案是在minimatch中,glob用它来比较路径。