Closed stodge closed 10 years ago
One way is to use the or operator, e.g. "|", between each filename, but you'd probably want to specify start and end and escape special characters. For the above, this regex should work:
/^(\.hgignore|bin|static\/extern|node_modules)$/
As of version 0.1.5, you can use arrays for the match, exclude, matchDir, and excludeDir options. For your example, you should now be able to implement the above as follows:
dir.readFiles(__dirname, {
exclude: ['.hgignore', 'bin', 'static/extern', 'node_modules']
}, function(err, content, next) {
if (err) throw err;
console.log('content:', content);
next();
},
function(err, files){
if (err) throw err;
console.log('finished reading files:',files);
});
Hopefully this will make working with arbitrary lists of filenames easier when doing matches or excludes.
You'll have to forgive my ignorance as I don't "get" regexes. How would I exclude multiple directories? I need to exclude all of these directories:
... and perhaps more.
Thanks