Tag: glob

什么是最简单的方法前缀在JavaScript中的所有string与“!”(感叹号)?

当我想要包含或排除系统文件时,我使用了两个variables(使用minimatch glob语法,其中!表示排除)。 var systemFiles = ['node_modules/**/*', '.git/**/*']; var ignoredSystemFiles = ['!node_modules/**/*', '!.git/**/*']; 但是这感觉有点多余。 有没有一种简单的方法来将ignoredSystemFiles数组转换为ignoredSystemFiles数组(即:用!在ignoredSystemFiles所有项前缀)? 我知道!systemFiles不起作用,但是像这样紧凑的东西会很棒,因为它可以让我消除ignoredSystemFilesvariables。

如果path以“./”开头并且nocase:true – 错误或预期,Node glob不匹配任何东西?

复制说明: 从一个空目录开始,我创build了一个package.json : { "dependencies": { "glob": "7.1.1" } } 7.1.1是编辑这篇文章时的最新版本。 然后我运行npm install ,最后是node命令: > var glob = require('glob'); undefined > glob.sync('*'); [ 'node_modules', 'package.json' ] > glob.sync('./*'); [ './node_modules', './package.json' ] 这一切都是有道理的,但在这里它变得奇怪: > glob.sync('*', { nocase: true }); [ 'node_modules', 'package.json' ] > glob.sync('./*', { nocase: true }); [] 我认为nocase只应该影响大小写敏感性。 我无法看到文档中的任何内容,也找不到任何Google结果来解释此行为。 这是一个错误还是这样做是有道理的,我目前不明白?

包含所有的.d.ts,但是在gulp.src的glob上排除.ts

背景 在我的Angular2项目上编译我的Typescript文件之后,我将拥有以下目录结构(简化): ├── app │ └── app.module.d.ts │ └── app.module.js │ └── app.module.ts │ └── index.d.ts │ └── index.js │ └── index.ts │ └── sample.component.d.ts │ └── sample.component.js │ └── sample.component.ts │ └── sample.component.html │ └── sample.component.css 问题 使用gulp@3.9.1和gulp.src() ,我怎样才能创build一个glob数组,其中包括app文件夹下的所有文件,但忽略与.d.ts文件对应的.ts文件?

GruntJSrecursion通配差异

GruntJS节点通配中的**/*.js 。js和{,*/}*.js 。js有什么区别?

Globs&NPM Minimatch:除特定目录外,recursion匹配所有文件和目录

鉴于目录结构: /Users/doge/very/amaze.js /usr/local/bin/wow /node_modules/ /css/ /css/somefile.css /lib/ /somelib/ /anotherlib/somedir/finallib.js /index.html /somefile.test /somelib/file.html /firstdir/seconddir/file.css /node_modules.txt 我将如何仅使用extglob排除node_modules目录? /!(node_modules) 以上内容匹配除了node_modules目录和文本文件(我们希望包含的文件)之外的所有内容。 它也不会遵循recursion匹配的目录。 /!(node_modules)/** 这个更接近,但是它也排除了根目录中的所有文件。 即使它包含在根级别的文件,我猜它会排除node_modules.txt文件。 PS这是用于使用grunt-ssh和minimatch节点模块进行文件匹配。

抛出新的TypeError('callback提供同步glob')?

执行错误的细节: #节点app.js throw new TypeError('callback provided to sync glob') ^ TypeError: callback provided to sync glob at glob (C:\Users\z\Documents\node_modules\glob\glob.js:70:13) at Object.module.exports.getGlobbedFiles (C:\Users\z\Documents\Server\Config\config.js:31:4) at Object.<anonymous> (C:\Users\z\Documents\Server\app.js:102:10) 我使用glob 5.0.14来启动meanjs应用程序。 这是我的config.js: var _ = require('lodash'), glob = require('glob'); module.exports.getGlobbedFiles = function(globPatterns, removeRoot) { var _this = this; var urlRegex = new RegExp('^(?:[az]+:)?\/\/', 'i'); var output = []; if […]

吞噬空白的目录

在我的build设中,我完成了一个任务, 在所有的编译之后运行,发生了uglifying和minification。 这个任务简单地将src中的所有内容复制到尚未被早期任务触及/处理的dest目录中。 我遇到的小问题是这导致dest目录中的空目录。 有没有办法告诉gulp.src glob只包含模式匹配中的文件(如提供'is_file'标志)? 谢谢。

窗口npm中的全局通配符

我试图让npm在一个脚本文件夹上build立一个浏览器。 问题是,我在窗户上,做文件夹/ *。JS似乎并没有工作。 我已经尝试全局安装glob,但每当我运行一个生成命令,错误回来说:“无法find模块”c:\ www \ project \ static \ js \ components * .js'。 这是我的package.json: { "name": "TEST", "description": "ITS ME MARIO", "author": "JJ", "version": "0.0.1", "dependencies": { "connect": "1.8.5", "express": "2.5.2", "jade": "0.20.0", "mongoose": "3.8.x", "socket.io": "0.8.7" }, "devDependencies": { "vows": "0.5.x", "mocha": "*", "should": "*", "jshint": "latest", "browserify": "latest", "rimraf": "latest", "hashmark": […]

glob在Node.js中只返回匹配(无前导path)

我需要glob ./../path/to/files/**/*.txt而不是像这样接收匹配: ./../path/to/files/subdir/file.txt 我需要删除根目录: subdir/file.txt 目前,我有: oldwd = process.cwd() process.chdir(__dirname + "/../path/to/files") glob.glob("**/*.txt", function (err, matches) { process.chdir(oldwd) }); 但是这有点难看,似乎也有一个竞争条件:有时候这个环球会发生在老年人身上。 所以这一定要去。 我正在考虑简单地映射matches和剥离string操作的主要path。 由于glob返回匹配解决的dotdirs,我将不得不做同样的我的search和replacestring,我想。 这只是混乱,我不知道是否有一个更好的(内置或库?)方式来处理这个问题。 那么,在Node.js中完成一个漂亮的,整齐的和正确的方法,并且只是获得“匹配”部分? JavaScript和CoffeeScript都可以

节点/ JavaScript全局文件/path匹配语法,通配符等

我刚刚findhttp://gruntjs.com/configuring-tasks#globbing-patterns ,这是我find的最有帮助的参考。 我一直在看: 有关glob模式语法的更多信息,请参阅node-glob和minimatch文档。 然而,我似乎无法find一个详尽的语法/用法列表。 这些testing可能是最好的参考,但仍然不是特别容易破译。 看来我必须错过一些关键的文档来源。 我想知道以下的区别: path path/ path/* path/*.* path/** path/**/ path/**/* path/**/*.* 以及我可能已经省略的任何其他重要的变化。 我猜这在应用node-glob风格匹配( 'public/**/*.*' )和.gitignore ( node_modules )时会node_modules ,因为在前者中,需要明确包含所有内容, ,并在gitignore,这是通过忽略任何目录自动处理。 它是否正确?