Skip to content

Commit d2e2779

Browse files
committed
Add: inquirer prompt
1 parent 199f9c3 commit d2e2779

File tree

5 files changed

+58
-10
lines changed

5 files changed

+58
-10
lines changed

lib/cli.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
2+
// import { argv } from 'yargs';
3+
import sgcPrompt from './sgcPrompt';
24

3-
import { argv } from 'yargs';
4-
5-
console.log(argv);
5+
sgcPrompt();

lib/router.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/sgcPrompt.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import chalk from 'chalk';
2+
import inquirer from 'inquirer';
3+
import getConfig from './getConfig';
4+
5+
const sgcPrompt = () => {
6+
const config = getConfig();
7+
const choices = [];
8+
9+
config.types.forEach((type) => {
10+
const emoji = `${type.emoji} ` || '';
11+
const prefix = type.prefix;
12+
const description = type.description || '';
13+
14+
choices.push({
15+
value: emoji + prefix,
16+
name: `${chalk.bold(prefix)} ${description}`,
17+
});
18+
});
19+
20+
const questions = [{
21+
type: 'list',
22+
name: 'type',
23+
message: 'Select the type of your commit:',
24+
choices,
25+
}, {
26+
type: 'input',
27+
name: 'description',
28+
message: 'Describe your commit message:',
29+
}, {
30+
type: 'confirm',
31+
name: 'moreInfo',
32+
message: 'You want to add more information to your commit?',
33+
default: false,
34+
}, {
35+
type: 'editor',
36+
name: 'editor',
37+
message: 'this is the message',
38+
when: answers => answers.moreInfo,
39+
default: answers => `${answers.type} ${answers.description}`,
40+
}];
41+
42+
inquirer.prompt(questions).then((answers) => {
43+
// TODO commit message
44+
console.log(answers);
45+
});
46+
};
47+
48+
export default sgcPrompt;

test/router.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/sgcPrompt.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import test from 'ava';
2+
import prompt from '../lib/sgcPrompt';
3+
4+
test((t) => {
5+
prompt();
6+
// t.true(prompt());
7+
});

0 commit comments

Comments
 (0)