felixge/node-require-all

add option to skip requiring all if directory does not exist

pleerock opened this issue · 1 comments

Need to have ability not to do require-all in directories that does not exist, without manually checks if directory is actually exist. This is required to prevent errors like ENOENT: no such file or directory

Hi! This is something you would need to do in your call, as in don't call this module if you don't want to load the directory. Calling the function signals "I want to require the modules in this directory", thus if we can't do that, it's an error.

var dir = __dirname + '/lib';
var libs = fs.existsSync(dir) ? require('require-all')(dir) : {};