Last active
August 29, 2015 14:08
-
-
Save alanhoff/99a1610671ed6ebcbc37 to your computer and use it in GitHub Desktop.
index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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