Created
August 15, 2014 19:11
-
-
Save renancouto/ffd65e96a016133d9eb1 to your computer and use it in GitHub Desktop.
Read all json files on the current dir and return an object with their content, using their filenames (in camelCase) as keys.
This file contains hidden or 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
/*jslint node:true, nomen:true, stupid:true*/ | |
'use strict'; | |
/** | |
* dependencies | |
*/ | |
var fs = require('fs'); | |
var path = require('path'); | |
var s = require('string'); | |
/** | |
* settings | |
*/ | |
var data = {}; | |
/** | |
* get dir files | |
*/ | |
fs.readdirSync(__dirname).forEach(function (item) { | |
if (path.extname(item) === '.json') { | |
data[s(path.basename(item, '.json')).camelize().s] = require('./' + item); | |
} | |
}); | |
/** | |
* public | |
*/ | |
module.exports = data; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment