Skip to content

Commit d6e6076

Browse files
committed
🔨 Refactor: move prompt from lib/promptConfig to lib/cli
1 parent 3c17c1d commit d6e6076

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

lib/cli.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
#!/usr/bin/env node
2-
import promptConfig from './promptConfig';
2+
import chalk from 'chalk';
3+
import execa from 'execa';
4+
import inquirer from 'inquirer';
5+
import { config, choices, questions } from './promptConfig';
36

4-
const cli = promptConfig;
5-
const config = cli.config();
6-
const choices = cli.choices(config);
7-
const questions = cli.questions(choices);
7+
const configuration = config();
8+
const choicesList = choices(configuration);
9+
const questionsList = questions(choicesList);
810

9-
cli.prompt(questions);
11+
inquirer.prompt(questionsList).then((answers) => {
12+
const message = answers.moreInfo ? `${answers.editor}` : `${answers.type} ${answers.description}`;
13+
14+
return execa('git', ['commit', '-m', message])
15+
.then(result => console.log(result.stdout))
16+
.catch((err) => {
17+
console.error(chalk.red("Have you thought about 'git add' some files? Add files and try run following again:\n"));
18+
console.error(chalk.green(err.cmd));
19+
});
20+
});

0 commit comments

Comments
 (0)