Skip to content

Commit

Permalink
fix: empty property override when merge object
Browse files Browse the repository at this point in the history
  • Loading branch information
e-cloud committed Sep 26, 2016
1 parent 3e02d43 commit a8204d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/configLoader.js
Expand Up @@ -25,7 +25,7 @@ module.exports = {
function mergeConfig(...configs) {
logger.trace('merge all config')

return butil.assignWithValid({}, ...configs)
return butil.mergeWithValid({}, ...configs)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/util.js
Expand Up @@ -63,14 +63,14 @@ function assignPredict(older, newer) {

function mergeWithValid(...sources) {
sources.push(mergeCustomizer)
return _.assignWith(...sources)
return _.mergeWith(...sources)
}

function mergeCustomizer(older, newer) {
if (Array.isArray(older)) {
return older.concat(newer)
} else if (_.isObject(older) && _.isObject(newer)) {
return assignWithValid(older, newer)
return mergeWithValid(older, newer)
}

return isEmpty(newer) ? older : newer
Expand Down

0 comments on commit a8204d4

Please sign in to comment.