aseemk / requireDir

Node.js helper to require() directories.
MIT License
484 stars 60 forks source link

Filter #14

Closed simon-p-r closed 6 years ago

simon-p-r commented 9 years ago

Hi

Is there no option to filter out directories you don't want to require? Folders such as .git or node_modules are 2 directories you may want to filter from a directory require.

sholladay commented 8 years ago

There doesn't seem to be an option for that, but luckily both of your example cases should be handled already. require-dir actively ignores node_modules. And the strategy it uses for determining basenames (removes extensions), should lead to an empty string for anything starting with ., which hopefully wouldn't get required or end up in the result list, but I haven't tested that.

cxoltero commented 8 years ago

I guess you could do something like this: .src(['!./src/js/*/.test.js', './src/js/*/.js'])

you just tell the array not to take the test files in this case. in your case would be something like:

.src["!./.git", "!./node_modules"]

yocontra commented 6 years ago

done, will be published in next npm release

sunnixx commented 4 years ago

Hi anything on this ?

yocontra commented 4 years ago

@sunnixx This has been published already, see the README https://github.com/aseemk/requireDir#options