From 08cf19c36de6c34b4502435d9b12097474db5829 Mon Sep 17 00:00:00 2001 From: streamich Date: Mon, 20 Jan 2020 23:52:50 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Allow=20emojis=20in=20no?= =?UTF-8?q?n-interactive=20and=20set=20defaults?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/cli.js | 15 ++++++++++++--- lib/runNonInteractiveMode.js | 14 +++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 14389850..cd6c7515 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -35,7 +35,16 @@ const main = async () => { params[arg] = true; } - const {'dry-run': isDryRun, 'non-interactive': isNonInteractiveMode, hook: isHook, ...passThroughParams} = params; + const {'dry-run': isDryRun, 'non-interactive': isNonInteractiveMode, hook: isHook, body, breaking, issues, lerna, scope, subject, type, ...passThroughParams} = params; + const cliAnswers = { + body, + breaking, + issues, + lerna, + scope, + subject, + type + }; if (isDryRun) { // eslint-disable-next-line no-console @@ -43,9 +52,9 @@ const main = async () => { } if (isNonInteractiveMode) { - await runNonInteractiveMode(state, passThroughParams); + await runNonInteractiveMode(state, cliAnswers); } else { - await runInteractiveQuestions(state); + await runInteractiveQuestions(state, cliAnswers); } const message = formatCommitMessage(state); diff --git a/lib/runNonInteractiveMode.js b/lib/runNonInteractiveMode.js index 2836e9e9..f3de073e 100644 --- a/lib/runNonInteractiveMode.js +++ b/lib/runNonInteractiveMode.js @@ -1,10 +1,14 @@ -const runNonInteractiveMode = (state, params) => { - state.config.disableEmoji = true; +const runNonInteractiveMode = (state, {type = 'chore', subject = 'automated commit', ...restAnswers}) => { + const answers = { + subject, + type, + ...restAnswers + }; Object.keys(state.answers).forEach((key) => { - if (params[key]) { - state.answers[key] = params[key]; - delete params[key]; + if (answers[key]) { + state.answers[key] = answers[key]; + delete answers[key]; } }); };