feat(commit.ts): enable users to edit commit message before committing
This commit is contained in:
+20
-8
@@ -1,5 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
confirm,
|
text,
|
||||||
intro,
|
intro,
|
||||||
isCancel,
|
isCancel,
|
||||||
multiselect,
|
multiselect,
|
||||||
@@ -85,15 +85,27 @@ ${commitMessage}
|
|||||||
${chalk.grey('——————————————————')}`
|
${chalk.grey('——————————————————')}`
|
||||||
);
|
);
|
||||||
|
|
||||||
const isCommitConfirmedByUser =
|
const userAction = skipCommitConfirmation
|
||||||
skipCommitConfirmation ||
|
? 'Yes'
|
||||||
(await confirm({
|
: await select({
|
||||||
message: 'Confirm the commit message?'
|
message: 'Confirm the commit message?',
|
||||||
}));
|
options: [
|
||||||
|
{ value: 'Yes', label: 'Yes' },
|
||||||
|
{ value: 'No', label: 'No' },
|
||||||
|
{ value: 'Edit', label: 'Edit' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
if (isCancel(isCommitConfirmedByUser)) process.exit(1);
|
if (isCancel(userAction)) process.exit(1);
|
||||||
|
|
||||||
if (isCommitConfirmedByUser) {
|
if (userAction === 'Edit') {
|
||||||
|
commitMessage = await text({
|
||||||
|
message: 'Please edit the commit message: (press Enter to continue)',
|
||||||
|
initialValue: commitMessage
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userAction === 'Yes' || userAction === 'Edit') {
|
||||||
const committingChangesSpinner = spinner();
|
const committingChangesSpinner = spinner();
|
||||||
committingChangesSpinner.start('Committing the changes');
|
committingChangesSpinner.start('Committing the changes');
|
||||||
const { stdout } = await execa('git', [
|
const { stdout } = await execa('git', [
|
||||||
|
|||||||
Reference in New Issue
Block a user