**/*.js
和 {,*/}*.js
在 GruntJS Node 通配中有什么区别?
最佳答案
GruntJS 使用 globbing patterns基于 node-glob图书馆。
基于此,*
将具有以下含义:
path/*
-path
中的所有文件和文件夹不递归path/**
-path
中的所有内容递归path/*.*
- 名称中包含点的所有文件和文件夹;匹配file.txt
、.gitignore
、noExtension.
等
为了说明一些问题,您可以在 glob patterns 上阅读这篇文章.
在文档中他们有 Glob Primer ,其中有一个例子:
Before parsing the path part patterns, braced sections are expanded into a set. Braced sections start with
{
and end with}
, with any number of comma-delimited sections within. Braced sections may contain slash characters, soa{/b/c,bcd}
would expand intoa/b/c
andabcd
.
这正是您的案例 {,*/}*.js
的内容。
我强烈建议使用语法 **
(在你的例子中是 **/*.js
,用于过滤 .js
仅文件)当您需要递归迭代路径时。
关于node.js - GruntJS 递归 globbing 区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30561001/