node-filewalker icon indicating copy to clipboard operation
node-filewalker copied to clipboard

Ignoring folders

Open germtb opened this issue 8 years ago • 5 comments

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.

germtb avatar Oct 26 '16 10:10 germtb

You can filter filepaths with the matchRegExp option.

Try this:

filewalker('/', {
  matchRegExp: /^((?!(node_modules|\.git)).)*$/
})

oleics avatar Oct 26 '16 13:10 oleics

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.

germtb avatar Oct 26 '16 14:10 germtb

I just checked, and doing this check before the enqueing of the dir will make it visibly faster.

germtb avatar Oct 26 '16 15:10 germtb

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.

oleics avatar Oct 27 '16 09:10 oleics

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.

germtb avatar Oct 27 '16 11:10 germtb