Skip to content

Commit 273138f

Browse files
committed
Feat: add spawn
1 parent 57d1631 commit 273138f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/sgcPrompt.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import chalk from 'chalk';
2+
import execa from 'execa';
23
import inquirer from 'inquirer';
34
import getConfig from './getConfig';
45

6+
const cwd = process.cwd();
7+
58
const sgcPrompt = () => {
69
const config = getConfig();
710
const choices = [];
@@ -34,14 +37,20 @@ const sgcPrompt = () => {
3437
}, {
3538
type: 'editor',
3639
name: 'editor',
37-
message: 'this is the message',
40+
message: 'This will let you add more information',
3841
when: answers => answers.moreInfo,
39-
default: answers => `${answers.type} ${answers.description}`,
42+
default: answers => `${answers.type} ${answers.description}\n\n\n`,
4043
}];
4144

4245
inquirer.prompt(questions).then((answers) => {
43-
// TODO commit message
44-
console.log(answers);
46+
const message = answers.moreInfo ? `"${answers.editor}"` : `"${answers.type} ${answers.description}"`;
47+
48+
execa('git', ['commit', '-m', message])
49+
.then((result) => console.log(process.stdout))
50+
.catch((err) => {
51+
console.error(chalk.red("Have you thought about 'git add' some files? Add files and try run following again:\n"));
52+
console.error(chalk.green(err.cmd))
53+
});
4554
});
4655
};
4756

0 commit comments

Comments
 (0)