我有一种情况,我试图使用grunt来过滤代码库,不包括特定的文件夹.
grunt在引擎盖下使用minimatch(类似于bsdglob)来匹配文件,但我似乎不知道如何进行匹配.gitignore排除文件夹的样式.
我想吞下这个:
ignoreme
并匹配这些:
/folder/path/here/to/something/ok.js
/another/folder/path.js
/test.js
但不符合以下条件:
/folder/ignoreme/something.js
/folder/path/here/to/ignoreme/metoo/file.js
这将匹配所有内容,包括ignoreme:
/**/*.js
所以我想我可以做一些类似的事情:
/**/!(ignoreme)/**/*.js
但这与ignoreme文件夹中的文件相匹配.
我已经习惯了正则表达式,但似乎不知道如何在这里重复一个模式或其他东西——我还try 了以下内容:
/(!(ignoreme)|*)*/*.js
希望容器会重复,但这不起作用,它只是无法匹配所有内容.
有没有办法将正则表达式传递给grunt文件路径,或者让它为我工作?
Update:
以下是我目前处理这个问题的方式:
var pattern = /\/ignoreme\//
var files = grunt.file.expandFiles(arrayOfFilesPassedToMinimatch).filter(function(f){
return !pattern.test(f)
})
我仍然很感兴趣,如果文件夹排除在minimatch是可能的.