node-filewalker
node-filewalker copied to clipboard
Ignoring folders
It could be useful to provide a way to ignore folders (node_modules, .git). At the moment I am doing that postprocessing the files, but if done earlier it could save up performance.
You can filter filepaths with the matchRegExp
option.
Try this:
filewalker('/', {
matchRegExp: /^((?!(node_modules|\.git)).)*$/
})
I suspect that is checking each file inside .git and node_modules, am I wrong? If that is the case, performance wise, there could be better solutions.
I just checked, and doing this check before the enqueing of the dir will make it visibly faster.
You are right.
Even more: matchRegExp
option in it's current implementation does make no sense, as one can always check filename-extensions in user-land (which was the reason for the PR that implemented matchRegExp
..)
matchRegExp
should test directory-paths and maybe filepaths too.
Following this conversation, yesterday I raised a PR (https://github.com/oleics/node-filewalker/pull/14) to add the possibility to ignore folders. It doesn't use matchRegExp
but maybe it would make sense to, since it could simplify the options the user needs to pass.