mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-08-01 07:26:10 +02:00
* Use lodash for Config.js / config.json merge
This commit is contained in:
parent
ab40eb1fd4
commit
82f3bc7601
3 changed files with 22 additions and 25 deletions
|
@ -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);
|
||||
}
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue