Skip to content

Commit 602ce22

Browse files
yashk2000agg-shambhavi
authored andcommitted
🐛 cli: Allow editing commits in editor and add descriptions
1 parent db267c6 commit 602ce22

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/inquirer.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,10 @@ module.exports = {
183183
branch = conf['current_branch'];
184184
commitMsg = conf['current_commit_message'];
185185
suggestedBranch = "Suggested branch name(press enter to continue or type an alternate): " + branch + "\n";
186-
suggestedCommitMsg = "Suggested commit message(press enter to continue or type an alternate): " + commitMsg + "\n";
186+
suggestedCommitMsg = "Suggested commit message(press enter to continue or \"e\" to type an alternate): " + commitMsg + "\n";
187187

188188
inquirer.prompt([
189189
{
190-
// expects issue number as response
191190
type: 'string', message: suggestedBranch, name: 'branch'
192191
}
193192
])
@@ -196,12 +195,21 @@ module.exports = {
196195
conf.current_branch = answers['branch'];
197196
}
198197
inquirer.prompt([{
199-
// displays emoji based MCQ
200198
type: 'string', message: suggestedCommitMsg, name: 'commit'
201199
}]).then(
202200
ans => {
203-
if (ans['commit'] != "") {
204-
conf.current_commit_message = ans['commit'];
201+
if (ans['commit'] === "e") {
202+
inquirer.prompt([{
203+
type: 'editor', message: commitMsg + "\n", name: 'commitCustom'
204+
}]).then(
205+
ans2 => {
206+
console.log(ans2['commitCustom']);
207+
conf.current_commit_message = ans2.commitCustom;
208+
fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => {
209+
if (err) console.log('Error writing file:', err)
210+
})
211+
}
212+
)
205213
}
206214
fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => {
207215
if (err) console.log('Error writing file:', err)

0 commit comments

Comments
 (0)