node.js - GruntJS 递归 globbing 区别

标签 node.js gruntjs glob

**/*.js{,*/}*.js 在 GruntJS Node 通配中有什么区别?

最佳答案

GruntJS 使用 globbing patterns基于 node-glob图书馆。

基于此,*将具有以下含义:

  • path/* - path 中的所有文件和文件夹递归
  • path/** - path 中的所有内容递归
  • path/*.* - 名称中包含点的所有文件和文件夹;匹配 file.txt.gitignorenoExtension.

为了说明一些问题,您可以在 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, so a{/b/c,bcd} would expand into a/b/c and abcd.

这正是您的案例 {,*/}*.js 的内容。

我强烈建议使用语法 **(在你的例子中是 **/*.js,用于过滤 .js仅文件)当您需要递归迭代路径时。

关于node.js - GruntJS 递归 globbing 区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30561001/

相关文章:

bash - 通配 : Matching files names with a number in a script?

javascript - 在 ExpressJS 中将变量传递给 JavaScript

javascript - 我如何使用 browserify 安装不在 npm 上的库?

javascript - grunt watch 不工作并被挂起

node.js - 使用 grunt 时是否有必要为每个项目创建 node_modules 文件夹

python - 在 glob 中扩展星号

java - Node.js 套接字上的数据太多?

javascript - 在 nodemailer 中,如何格式化文本电子邮件正文

javascript - 一个 grunt 插件如何包装另一个插件

graphql - NextJs 使用 loadFilesSync 或 glob 加载多个文件,