Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
feat: 🎸 Allow emojis in non-interactive and set defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jan 20, 2020
1 parent 61b40db commit 08cf19c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
15 changes: 12 additions & 3 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,26 @@ 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
console.log('Running in dry mode.');
}

if (isNonInteractiveMode) {
await runNonInteractiveMode(state, passThroughParams);
await runNonInteractiveMode(state, cliAnswers);
} else {
await runInteractiveQuestions(state);
await runInteractiveQuestions(state, cliAnswers);
}

const message = formatCommitMessage(state);
Expand Down
14 changes: 9 additions & 5 deletions lib/runNonInteractiveMode.js
Original file line number Diff line number Diff line change
@@ -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];
}
});
};
Expand Down

0 comments on commit 08cf19c

Please sign in to comment.