From feb99c6c92e28382f3cfe8fec57929a315274a44 Mon Sep 17 00:00:00 2001 From: Joel Gallant Date: Tue, 2 Oct 2018 22:09:37 -0600 Subject: [PATCH] WIP #83 --- src/Config.js | 6 ++++++ test/ConfigExtendCommand.spec.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/Config.js b/src/Config.js index a1d0f48..7abecbf 100644 --- a/src/Config.js +++ b/src/Config.js @@ -172,6 +172,12 @@ class Config { return ConfigCommandInvoker.invoke(commandNames.EXTEND, this, ...values); } + extendOptional(...values) { + try { + return ConfigCommandInvoker.invoke(commandNames.EXTEND, this, ...values); + } catch (e) {} + } + /** * @example * import Config from 'webpack-config'; diff --git a/test/ConfigExtendCommand.spec.js b/test/ConfigExtendCommand.spec.js index 245a5e4..ac9265e 100644 --- a/test/ConfigExtendCommand.spec.js +++ b/test/ConfigExtendCommand.spec.js @@ -156,5 +156,11 @@ describe('ConfigExtendCommand', () => { bar: 'bar1' }); }); + + it('should fail gracefully when file not found', () => { + config.extendOptional('invalid-config-file'); + + expect(config.toObject()).toEqual({}); + }); }); });