Skip to content

Instantly share code, notes, and snippets.

@IrakliJani
Created June 2, 2014 10:53
Show Gist options
  • Save IrakliJani/7682fc15d15c5c12c856 to your computer and use it in GitHub Desktop.
Save IrakliJani/7682fc15d15c5c12c856 to your computer and use it in GitHub Desktop.
var fs = require('fs');
module.exports = function () {
return fs
.readdirSync(__dirname)
.filter(function (file) { return /\.json$/.test(file); })
.reduce(function (config, file) {
return extend(config, require(__dirname + '/' + file));
}, {});
};
function extend (origin, add) {
if (!add || typeof add !== 'object') return origin;
var keys = Object.keys(add);
var i = keys.length;
while (i--) {
origin[keys[i]] = add[keys[i]];
}
return origin;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment