style(commit.ts): add question mark to confirm message

feat(commit.ts): add support for pushing to selected remote instead of default remote
refactor(commit.ts): extract push command to a function and reuse it for both default and selected remote
This commit is contained in:
di-sukharev
2023-03-28 11:22:57 +08:00
parent 18dcb8e8c2
commit 1c113c2901
+14 -3
View File
@@ -63,7 +63,7 @@ ${chalk.grey('——————————————————')}`
);
const isCommitConfirmedByUser = await confirm({
message: 'Confirm the commit message'
message: 'Confirm the commit message?'
});
if (isCommitConfirmedByUser && !isCancel(isCommitConfirmedByUser)) {
@@ -86,11 +86,19 @@ ${chalk.grey('——————————————————')}`
if (isPushConfirmedByUser && !isCancel(isPushConfirmedByUser)) {
const pushSpinner = spinner();
pushSpinner.start(`Running \`git push ${remotes[0]}\``);
const { stdout } = await execa('git', ['push', '--verbose', remotes[0]]);
const { stdout } = await execa('git', [
'push',
'--verbose',
remotes[0]
]);
pushSpinner.stop(
`${chalk.green('✔')} successfully pushed all commits to ${remotes[0]}`
);
if (stdout) outro(stdout);
}
} else {
@@ -101,8 +109,11 @@ ${chalk.grey('——————————————————')}`
if (!isCancel(selectedRemote)) {
const pushSpinner = spinner();
pushSpinner.start(`Running \`git push ${selectedRemote}\``);
const { stdout } = await execa('git', ['push', selectedRemote]);
pushSpinner.stop(
`${chalk.green(
'✔'
@@ -197,4 +208,4 @@ export async function commit(
process.exit(1);
}
process.exit(0);
}
}