From 34aee9e190314afc22a3e94a3c66bd1c839da22c Mon Sep 17 00:00:00 2001 From: Pierre-Denis Vanduynslager Date: Sun, 17 Sep 2017 19:03:23 -0400 Subject: [PATCH] fix: Accept undefined pluginConfig --- lib/index.js | 4 ++-- test/integration.test.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 4db5d676..39c22d0f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -15,7 +15,7 @@ const DEFAULT_RELEASE_RULES = require('./default/release-rules'); /** * Determine the type of release to create based on a list of commits. * - * @param {Object} pluginConfig semantic-release configuration + * @param {Object} [pluginConfig={}] semantic-release configuration * @param {string} pluginConfig.preset conventional-changelog preset ('angular', 'atom', 'codemirror', 'ember', 'eslint', 'express', 'jquery', 'jscs', 'jshint') * @param {string} pluginConfig.config requierable npm package with a custom conventional-changelog preset * @param {string|Array} pluginConfig.releaseRules a string to load an external module or an `Array` of rules. @@ -24,7 +24,7 @@ const DEFAULT_RELEASE_RULES = require('./default/release-rules'); * @param {Array} options.commits array of commits * @param {commitAnalyzerCallback} callback The callback called with the release type. */ -module.exports = async (pluginConfig, {commits}, callback) => { +module.exports = async (pluginConfig = {}, {commits}, callback) => { try { const releaseRules = loadReleaseRules(pluginConfig); const config = await loadParserConfig(pluginConfig); diff --git a/test/integration.test.js b/test/integration.test.js index b73a8c41..02cf8f43 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -187,3 +187,10 @@ test('Handle error in "conventional-changelog-parser" and wrap in "SemanticRelea t.true(error instanceof SemanticReleaseError); }); + +test('Accept an undefined "pluginConfig"', async t => { + const commits = [{message: 'fix(scope1): First fix'}, {message: 'feat(scope2): Second feature'}]; + const releaseType = await pify(commitAnalyzer)(undefined, {commits}); + + t.is(releaseType, 'minor'); +});