From b0be6bf6993910eb22601bbcdf0db2d4b9412a8b Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Tue, 20 Aug 2019 18:07:47 +0200 Subject: [PATCH] fix: skip notification when args not given (#199) --- packages/shipjs/src/util/slack.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/shipjs/src/util/slack.js b/packages/shipjs/src/util/slack.js index 7c86fd7a..10d897ab 100644 --- a/packages/shipjs/src/util/slack.js +++ b/packages/shipjs/src/util/slack.js @@ -3,7 +3,7 @@ import { IncomingWebhook } from '@slack/webhook'; async function sendSlackMessage({ config, sendArguments }) { const { slackIncomingHook, slack } = config; - if (!slackIncomingHook) { + if (!slackIncomingHook || !sendArguments) { return; } const webhook = new IncomingWebhook(slackIncomingHook); @@ -27,9 +27,9 @@ export async function notifyPrepared({ } const sendArguments = - typeof prepared === 'string' - ? prepared - : prepared({ appName, version, pullRequestUrl }); + typeof prepared === 'function' + ? prepared({ appName, version, pullRequestUrl }) + : prepared; await sendSlackMessage({ config, @@ -51,9 +51,9 @@ export async function notifyReleaseStart({ } const sendArguments = - typeof releaseStart === 'string' - ? releaseStart - : releaseStart({ appName, version, latestCommitHash, latestCommitUrl }); + typeof releaseStart === 'function' + ? releaseStart({ appName, version, latestCommitHash, latestCommitUrl }) + : releaseStart; await sendSlackMessage({ config, @@ -76,15 +76,15 @@ export async function notifyReleaseSuccess({ } const sendArguments = - typeof releaseSuccess === 'string' - ? releaseSuccess - : releaseSuccess({ + typeof releaseSuccess === 'function' + ? releaseSuccess({ appName, version, latestCommitHash, latestCommitUrl, repoURL, - }); + }) + : releaseSuccess; await sendSlackMessage({ config,