From 47484f5eb2fa330cbbbb03bffadba524ad642081 Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Fri, 14 Dec 2018 15:58:58 -0500 Subject: [PATCH] feat: allow `publish` plugins to return `false` in order to signify no release was done --- lib/definitions/plugins.js | 2 +- test/definitions/plugins.test.js | 3 ++- test/index.test.js | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/definitions/plugins.js b/lib/definitions/plugins.js index f3516c33e7..23b49890c7 100644 --- a/lib/definitions/plugins.js +++ b/lib/definitions/plugins.js @@ -73,7 +73,7 @@ module.exports = { transform: (release, step, {nextRelease}) => ({ ...nextRelease, ...(release || {}), - ...step, + ...(release === false ? {} : step), }), }), }, diff --git a/test/definitions/plugins.test.js b/test/definitions/plugins.test.js index effca5c08c..0a6de485df 100644 --- a/test/definitions/plugins.test.js +++ b/test/definitions/plugins.test.js @@ -22,7 +22,7 @@ test('The "generateNotes" plugin output, if defined, must be a string', t => { t.true(plugins.generateNotes.outputValidator('string')); }); -test('The "publish" plugin output, if defined, must be an object', t => { +test('The "publish" plugin output, if defined, must be an object or "false"', t => { t.false(plugins.publish.outputValidator(1)); t.false(plugins.publish.outputValidator('string')); @@ -30,6 +30,7 @@ test('The "publish" plugin output, if defined, must be an object', t => { t.true(plugins.publish.outputValidator()); t.true(plugins.publish.outputValidator(null)); t.true(plugins.publish.outputValidator('')); + t.true(plugins.publish.outputValidator(false)); }); test('The "addChannel" plugin output, if defined, must be an object', t => { diff --git a/test/index.test.js b/test/index.test.js index 8b342ebee8..96185f9406 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -1139,7 +1139,7 @@ test('Allow local releases with "noCi" option', async t => { t.is(success.callCount, 1); }); -test('Accept "undefined" value returned by the "generateNotes" plugins', async t => { +test('Accept "undefined" value returned by "generateNotes" and "false" by "publish"', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd, repositoryUrl} = await gitRepo(true); // Add commits to the master branch @@ -1170,7 +1170,7 @@ test('Accept "undefined" value returned by the "generateNotes" plugins', async t const generateNotes1 = stub().resolves(); const notes2 = 'Release notes 2'; const generateNotes2 = stub().resolves(notes2); - const publish = stub().resolves(); + const publish = stub().resolves(false); const options = { branches: ['master'],