Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 什么是全局模式匹配所有不使用';t以下划线开头忽略目录中以下划线开头的那些?_Node.js_Glob_Minimatch - Fatal编程技术网

Node.js 什么是全局模式匹配所有不使用';t以下划线开头忽略目录中以下划线开头的那些?

Node.js 什么是全局模式匹配所有不使用';t以下划线开头忽略目录中以下划线开头的那些?,node.js,glob,minimatch,Node.js,Glob,Minimatch,给定目录结构: a/ b/ _private/ notes.txt c/ _3.txt 1.txt 2.txt d/ 4.txt 5.txt 如何编写选择以下路径的glob模式(与npm模块兼容) a/b/c/1.txt a/b/c/2.txt a/b/d/4.txt a/b/5.txt 以下是我尝试过的: // Find matching file paths inside "a/b/"...

给定目录结构:

a/
  b/
    _private/
      notes.txt
    c/
      _3.txt
      1.txt
      2.txt
    d/
      4.txt
    5.txt
如何编写选择以下路径的glob模式(与npm模块兼容)

a/b/c/1.txt
a/b/c/2.txt
a/b/d/4.txt
a/b/5.txt
以下是我尝试过的:

// Find matching file paths inside "a/b/"...
glob("a/b/[!_]**/[!_]*", (err, paths) => {
    console.log(paths);
});
但这只会发出:

a/b/c/1.txt
a/b/c/2.txt
a/b/d/4.txt
通过一些尝试和错误(以及的帮助),我发现以下内容似乎达到了我所期望的结果:

// Find matching file paths inside "a/b/"...
glob("a/b/**/*", {
    ignore: [
        "**/_*",        // Exclude files starting with '_'.
        "**/_*/**"  // Exclude entire directories starting with '_'.
    ]
}, (err, paths) => {
    console.log(paths);
});