Skip to content

Instantly share code, notes, and snippets.

@stringparser
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stringparser/55b4c8ca77baacac382b to your computer and use it in GitHub Desktop.
Save stringparser/55b4c8ca77baacac382b to your computer and use it in GitHub Desktop.
Boom, require dir
var fs = require('fs');
var path = require('path');
var fileList = fs.readdirSync(
path.resolve(path.dirname(module.parent.filename), path.basename(__dirname))
).slice(1);
exports = module.exports = { };
fileList.forEach(function(fileName){
var name = path.basename(fileName, path.extname(fileName));
exports[name] = require('./'+fileName);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment