From d12a029778c3261cd7a789bb7d76766a6eb0ed39 Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Fri, 14 Dec 2018 18:53:42 -0500 Subject: [PATCH] fix: return `false` in `addChannel` if step is skipped --- index.js | 5 +++++ test/add-channel.test.js | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/index.js b/index.js index 7a1f6b75..3b09dda1 100644 --- a/index.js +++ b/index.js @@ -90,11 +90,16 @@ async function addChannel(pluginConfig, context) { } catch (error) { debug(stdout); debug(error); + context.logger.log( `The command ${pluginConfig.cmd} wrote invalid JSON to stdout. The stdout content will be ignored.` ); + + return undefined; } } + + return false; } async function success(pluginConfig, context) { diff --git a/test/add-channel.test.js b/test/add-channel.test.js index 012f45b3..38ad7db7 100644 --- a/test/add-channel.test.js +++ b/test/add-channel.test.js @@ -76,3 +76,11 @@ test('Use "addChannelCmd" even if "cmd" is defined', async t => { const result = await addChannel(pluginConfig, context); t.deepEqual(result, {name: 'Release name', url: 'https://host.com/release/1.0.0'}); }); + +test('Return "false" if neither "addChannelCmd" nor "cmd" is defined', async t => { + const pluginConfig = {}; + const context = {stdout: t.context.stdout, stderr: t.context.stderr, logger: t.context.logger}; + + const result = await addChannel(pluginConfig, context); + t.is(result, false); +});