* Use lodash for Config.js / config.json merge

This commit is contained in:
Bryan Ashby 2015-08-05 22:22:17 -06:00
parent ab40eb1fd4
commit 82f3bc7601
3 changed files with 22 additions and 25 deletions

View file

@ -13,24 +13,6 @@ exports.init = init;
exports.getDefaultPath = getDefaultPath;
function init(configPath, cb) {
// Probably many better ways of doing this:
// :TODO: See http://jsfiddle.net/jlowery2663/z8at6knn/4/
var recursiveMerge = function(target, source) {
for(var p in source) {
try {
if(_.isObject(source)) {
target[p] = recursiveMerge(target[p], source[p]);
} else {
target[p] = source[p];
}
} catch(e) {
target[p] = source[p];
}
}
return target;
};
async.waterfall(
[
function loadUserConfig(callback) {
@ -48,8 +30,8 @@ function init(configPath, cb) {
}
});
},
function mergeWithDefaultConfig(menuConfig, callback) {
var mergedConfig = recursiveMerge(menuConfig, getDefaultConfig());
function mergeWithDefaultConfig(configJson, callback) {
var mergedConfig = _.defaultsDeep(configJson, getDefaultConfig());
callback(null, mergedConfig);
}
],