Created
June 2, 2014 10:53
-
-
Save IrakliJani/7682fc15d15c5c12c856 to your computer and use it in GitHub Desktop.
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
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