From d8e59cce531ecb16cbf1c450056cc3b077157309 Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Tue, 10 Jul 2018 15:42:39 -0400 Subject: [PATCH] fix: set default path to `generateNotes` object config --- lib/plugins/index.js | 5 +++-- test/plugins/plugins.test.js | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/plugins/index.js b/lib/plugins/index.js index 7c482b16..de61466d 100644 --- a/lib/plugins/index.js +++ b/lib/plugins/index.js @@ -17,9 +17,10 @@ module.exports = (options, pluginsPath, logger) => { if (isUndefined(options[type])) { pluginConfs = def; } else { + const defaultPaths = castArray(def); // If an object is passed and the path is missing, set the default one for single plugins - if (isPlainObject(options[type]) && !options[type].path && castArray(def).length === 1) { - options[type].path = def; + if (isPlainObject(options[type]) && !options[type].path && defaultPaths.length === 1) { + [options[type].path] = defaultPaths; } if (configValidator && !configValidator(options[type])) { errors.push(getError('EPLUGINCONF', {type, pluginConf: options[type]})); diff --git a/test/plugins/plugins.test.js b/test/plugins/plugins.test.js index 945da15e..2a3501d3 100644 --- a/test/plugins/plugins.test.js +++ b/test/plugins/plugins.test.js @@ -117,13 +117,15 @@ test.serial('Export plugins loaded from the dependency of a shareable config fil test('Use default when only options are passed for a single plugin', t => { const analyzeCommits = {}; + const generateNotes = {}; const success = () => {}; const fail = [() => {}]; - const plugins = getPlugins({analyzeCommits, success, fail}, {}, t.context.logger); + const plugins = getPlugins({analyzeCommits, generateNotes, success, fail}, {}, t.context.logger); // Verify the module returns a function for each plugin t.is(typeof plugins.analyzeCommits, 'function'); + t.is(typeof plugins.generateNotes, 'function'); t.is(typeof plugins.success, 'function'); t.is(typeof plugins.fail, 'function');