fix: handle null child config in merge (#790)

This commit is contained in:
Rhys Arkins 2017-09-13 20:29:20 +02:00 committed by GitHub
parent 37f3acf657
commit d6a45e5f47
2 changed files with 9 additions and 0 deletions

View file

@ -113,6 +113,9 @@ async function parseConfigs(env, argv) {
function mergeChildConfig(parentConfig, childConfig) {
logger.trace({ parentConfig, childConfig }, `mergeChildConfig`);
if (!childConfig) {
return parentConfig;
}
const config = { ...parentConfig, ...childConfig };
for (const option of definitions.getOptions()) {
if (

View file

@ -209,5 +209,11 @@ describe('config/index', () => {
const config = configParser.mergeChildConfig(parentConfig, {});
expect(config.packageRules).toHaveLength(2);
});
it('handles undefined childConfig', () => {
const parentConfig = { ...defaultConfig };
const configParser = require('../../lib/config/index.js');
const config = configParser.mergeChildConfig(parentConfig, undefined);
expect(config).toMatchObject(parentConfig);
});
});
});