From d6a45e5f479071a8f07d2db5316d08e174ff0de3 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@keylocation.sg>
Date: Wed, 13 Sep 2017 20:29:20 +0200
Subject: [PATCH] fix: handle null child config in merge (#790)

---
 lib/config/index.js       | 3 +++
 test/config/index.spec.js | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/lib/config/index.js b/lib/config/index.js
index 72085ab934..623258da44 100644
--- a/lib/config/index.js
+++ b/lib/config/index.js
@@ -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 (
diff --git a/test/config/index.spec.js b/test/config/index.spec.js
index d432a21b96..8d91482c9c 100644
--- a/test/config/index.spec.js
+++ b/test/config/index.spec.js
@@ -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);
+    });
   });
 });
-- 
GitLab