node.js glob pattern for excluding multiple files

后端 未结 6 1247
情话喂你
情话喂你 2020-12-24 10:56

I\'m using the npm module node-glob.

This snippet returns recursively all files in the current working directory.

var glob = require(\'glob\');
glob(         


        
6条回答
  •  别那么骄傲
    2020-12-24 11:32

    I suppose it's not actual anymore but i got stuck with the same question and found an answer.

    This can be done using only npm glob module. We need to use options as a second parameter to glob function

    glob('pattern', {options}, cb)
    

    There is an options.ignore pattern for your needs.

    var glob = require('glob');
    
    glob("**/*",{"ignore":['index.html', 'js', 'js/app.js', 'js/lib.js']}, function (err, files) {
      console.log(files);
    })
    

提交回复
热议问题