index.js
// Load all files inside this folder with a single require | |
var fs = require('fs'); | |
var str = require('underscore.string'); | |
var files = fs.readdirSync(__dirname); | |
module.exports = {}; | |
// Iterate over the files that we found, replace the name | |
// require the file and exports it | |
files = files.forEach(function(file){ | |
// We don't want an infinite loop | |
if(file === 'index.js') | |
return; | |
var name = str(file.replace(/-model.js/g, '')).chain().camelize().capitalize(); | |
module.exports[name] = require('./' + file); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment