fix(config): override config values instead of merging

Iterate over objects and copy over primitives and arrays
instead of using _.merge, as merge will not replace a config
entry completely. For arrays in a target object, the arrays
will have its indices replaced. This means if a source array
is empty, the target array will be left alone. Similarly,
if the target array is longer than a source array, there
will be indices not touched in the target array.
This commit is contained in:
Leonard Kim 2017-08-17 10:43:28 -07:00 committed by Lyubo Marinov
parent 5ef914602f
commit 5358f022ff
1 changed files with 10 additions and 3 deletions

View File

@ -175,9 +175,16 @@ export function overrideConfigJSON(
if (!_.isEmpty(configJSON)) { if (!_.isEmpty(configJSON)) {
logger.info( logger.info(
`Extending ${configName} ` `Extending ${configName} with: ${
+ `with: ${JSON.stringify(configJSON)}`); JSON.stringify(configJSON)}`);
_.merge(configObj, configJSON);
// eslint-disable-next-line arrow-body-style
_.mergeWith(configObj, configJSON, (oldValue, newValue) => {
// XXX We don't want to merge the arrays, we want to
// overwrite them.
return Array.isArray(oldValue) ? newValue : undefined;
});
} }
} }
} }