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

Commit

Permalink
feat: 🎸 non-interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
theashraf committed Jan 20, 2020
1 parent f12d2d0 commit 61b40db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const minimist = require('minimist');
const signale = require('signale');
const createState = require('./createState');
const runInteractiveQuestions = require('./runInteractiveQuestions');
const runNonInteractiveMode = require('./runNonInteractiveMode');
const formatCommitMessage = require('./formatCommitMessage');
const getGitRootDir = require('./util/getGitRootDir');

Expand Down Expand Up @@ -34,14 +35,18 @@ const main = async () => {
params[arg] = true;
}

const {'dry-run': isDryRun, hook: isHook, ...passThroughParams} = params;
const {'dry-run': isDryRun, 'non-interactive': isNonInteractiveMode, hook: isHook, ...passThroughParams} = params;

if (isDryRun) {
// eslint-disable-next-line no-console
console.log('Running in dry mode.');
}

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

const message = formatCommitMessage(state);

Expand Down
12 changes: 12 additions & 0 deletions lib/runNonInteractiveMode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const runNonInteractiveMode = (state, params) => {
state.config.disableEmoji = true;

Object.keys(state.answers).forEach((key) => {
if (params[key]) {
state.answers[key] = params[key];
delete params[key];
}
});
};

module.exports = runNonInteractiveMode;

0 comments on commit 61b40db

Please sign in to comment.