Skip to content

Instantly share code, notes, and snippets.

@JFKingsley
Created May 27, 2014 17:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JFKingsley/fb496604085785b675d1 to your computer and use it in GitHub Desktop.
Save JFKingsley/fb496604085785b675d1 to your computer and use it in GitHub Desktop.
// Load `*.js` under current directory as properties
// i.e., `User.js` will become `exports['User']` or `exports.User`
require('fs').readdirSync(__dirname + '/').forEach(function(file) {
if (file.match(/.+\.js/g) !== null && file !== 'index.js') {
var name = file.replace('.js', '');
exports[name] = require('./' + file);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment