Created
March 17, 2014 16:15
-
-
Save reggi/9602437 to your computer and use it in GitHub Desktop.
Requires every file in a directory into a single object.
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
var fs = require("fs"); | |
var _ = require("underscore"); | |
var dotty = require("dotty"); | |
module.exports = function() { | |
var files = fs.readdirSync(__dirname); | |
files = _.difference(files, ["index.js", ".DS_Store"]); | |
var result = {}; | |
_.each(files, function(value) { | |
var pieces = _.without(value.split("."), "js"); | |
var value = require("./" + value); | |
dotty.put(result, pieces, value); | |
}); | |
return result; | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment