I just found http://gruntjs.com/configuring-tasks#globbing-patterns, which is the most helpful reference I've found.
我刚刚找到了http://gruntjs.com/configuring-tasks#globbing-patterns,这是我发现的最有用的参考资料。
I keep seeing:
我一直看到:
For more on glob pattern syntax, see the node-glob and minimatch documentation.
有关glob模式语法的更多信息,请参阅node-glob和minimatch文档。
Yet, I can't seem to find an exhaustive list of the syntax/usage. These tests might be the best reference, yet still not particularly easy to decipher.
然而,我似乎找不到详尽的语法/用法列表。这些测试可能是最好的参考,但仍然不是特别容易破译。
It seems I must be missing some critical source of documentation.
看来我必须缺少一些重要的文档来源。
I'm wondering the differences between:
我想知道之间的区别:
path
path/
path/*
path/*.*
path/**
path/**/
path/**/*
path/**/*.*
and any other important variations that are related that I might have omitted. I'm guessing this applies differently when doing a node-glob
style matching ('public/**/*.*'
) and a .gitignore
(node_modules
), because in the former, you need to explicitly include everything, many layers deep, and in gitignore, this is handled automatically by ignoring any directory. Is this correct?
以及我可能省略的任何其他重要变化。我猜这在执行node-glob样式匹配('public /**/*.*')和.gitignore(node_modules)时有所不同,因为在前者中,你需要明确包含所有内容,多层深,在gitignore中,这是通过忽略任何目录自动处理的。它是否正确?
1 个解决方案
#1
14
First of all, I have never worked with node-glob
or minimatch
libraries. But probably I can still help. There's kind of known syntax for glob pattern matching, but frankly, a quick search in Google shows nothing short and clear. Probably this - http://hgbook.red-bean.com/read/file-names-and-pattern-matching.html#id381184 - is the best resource I've found. The article in Wikipedia is exhaustive and not readable - http://en.wikipedia.org/wiki/Glob_(programming).
首先,我从未使用过node-glob或minimatch库。但我可能仍然可以提供帮助。有一种已知的全局模式匹配语法,但坦率地说,谷歌的快速搜索没有简短明了。可能这个 - http://hgbook.red-bean.com/read/file-names-and-pattern-matching.html#id381184 - 是我找到的最好的资源。*中的文章详尽无遗且无法读取 - http://en.wikipedia.org/wiki/Glob_(programming)。
In short, IMHO for node-glob:
简而言之,IMHO for node-glob:
-
*
- stands for any number of characters for a filename, but can't stand for/
- * - 表示文件名的任意数量的字符,但不能代表/
-
**
- same as*
but crosses folder boundaries - ** - 与*相同但跨越文件夹边界
-
[abxy]
- can replace any one character from a list;[0-9]
can stand for any number - [abxy] - 可以替换列表中的任何一个字符; [0-9]可代表任何数字
Hence to your example:
因此,举个例子:
-
path/*
- all files and folders inpath
not recoursive - path / * - 路径中的所有文件和文件夹都不具有重复性
-
path/**
- everything inpath
recoursively - 路径/ ** - 路径中的所有内容
-
path/*.*
- all files and folders with point in name; matchesa.txt
,.hidden
,noextension.
,folder.out
, ... - path /*.* - 包含名称的所有文件和文件夹;匹配a.txt,.hidden,noextension。,folder.out,...
From minimatch documentation - https://github.com/isaacs/minimatch, - it does the same, but utilizes richer and slightly more difficult syntax of Regular Expressions. You may look here for a comprehesive reference - http://www.w3schools.com/js/js_regexp.asp. In short, path/.*
stands for anything below the path, but it's not clear if recursive or not. You may probably test it.
从minimatch文档 - https://github.com/isaacs/minimatch, - 它也是如此,但它使用了更复杂,更难处理的正则表达式语法。您可以在这里查看综合参考资料 - http://www.w3schools.com/js/js_regexp.asp。简而言之,路径/.*代表路径下方的任何东西,但不清楚是否递归。你可能会测试它。
#1
14
First of all, I have never worked with node-glob
or minimatch
libraries. But probably I can still help. There's kind of known syntax for glob pattern matching, but frankly, a quick search in Google shows nothing short and clear. Probably this - http://hgbook.red-bean.com/read/file-names-and-pattern-matching.html#id381184 - is the best resource I've found. The article in Wikipedia is exhaustive and not readable - http://en.wikipedia.org/wiki/Glob_(programming).
首先,我从未使用过node-glob或minimatch库。但我可能仍然可以提供帮助。有一种已知的全局模式匹配语法,但坦率地说,谷歌的快速搜索没有简短明了。可能这个 - http://hgbook.red-bean.com/read/file-names-and-pattern-matching.html#id381184 - 是我找到的最好的资源。*中的文章详尽无遗且无法读取 - http://en.wikipedia.org/wiki/Glob_(programming)。
In short, IMHO for node-glob:
简而言之,IMHO for node-glob:
-
*
- stands for any number of characters for a filename, but can't stand for/
- * - 表示文件名的任意数量的字符,但不能代表/
-
**
- same as*
but crosses folder boundaries - ** - 与*相同但跨越文件夹边界
-
[abxy]
- can replace any one character from a list;[0-9]
can stand for any number - [abxy] - 可以替换列表中的任何一个字符; [0-9]可代表任何数字
Hence to your example:
因此,举个例子:
-
path/*
- all files and folders inpath
not recoursive - path / * - 路径中的所有文件和文件夹都不具有重复性
-
path/**
- everything inpath
recoursively - 路径/ ** - 路径中的所有内容
-
path/*.*
- all files and folders with point in name; matchesa.txt
,.hidden
,noextension.
,folder.out
, ... - path /*.* - 包含名称的所有文件和文件夹;匹配a.txt,.hidden,noextension。,folder.out,...
From minimatch documentation - https://github.com/isaacs/minimatch, - it does the same, but utilizes richer and slightly more difficult syntax of Regular Expressions. You may look here for a comprehesive reference - http://www.w3schools.com/js/js_regexp.asp. In short, path/.*
stands for anything below the path, but it's not clear if recursive or not. You may probably test it.
从minimatch文档 - https://github.com/isaacs/minimatch, - 它也是如此,但它使用了更复杂,更难处理的正则表达式语法。您可以在这里查看综合参考资料 - http://www.w3schools.com/js/js_regexp.asp。简而言之,路径/.*代表路径下方的任何东西,但不清楚是否递归。你可能会测试它。