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
+13 -2
View File
@@ -63,7 +63,7 @@ ${chalk.grey('——————————————————')}`
); );
const isCommitConfirmedByUser = await confirm({ const isCommitConfirmedByUser = await confirm({
message: 'Confirm the commit message' message: 'Confirm the commit message?'
}); });
if (isCommitConfirmedByUser && !isCancel(isCommitConfirmedByUser)) { if (isCommitConfirmedByUser && !isCancel(isCommitConfirmedByUser)) {
@@ -86,11 +86,19 @@ ${chalk.grey('——————————————————')}`
if (isPushConfirmedByUser && !isCancel(isPushConfirmedByUser)) { if (isPushConfirmedByUser && !isCancel(isPushConfirmedByUser)) {
const pushSpinner = spinner(); const pushSpinner = spinner();
pushSpinner.start(`Running \`git push ${remotes[0]}\``); 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( pushSpinner.stop(
`${chalk.green('✔')} successfully pushed all commits to ${remotes[0]}` `${chalk.green('✔')} successfully pushed all commits to ${remotes[0]}`
); );
if (stdout) outro(stdout); if (stdout) outro(stdout);
} }
} else { } else {
@@ -101,8 +109,11 @@ ${chalk.grey('——————————————————')}`
if (!isCancel(selectedRemote)) { if (!isCancel(selectedRemote)) {
const pushSpinner = spinner(); const pushSpinner = spinner();
pushSpinner.start(`Running \`git push ${selectedRemote}\``); pushSpinner.start(`Running \`git push ${selectedRemote}\``);
const { stdout } = await execa('git', ['push', selectedRemote]); const { stdout } = await execa('git', ['push', selectedRemote]);
pushSpinner.stop( pushSpinner.stop(
`${chalk.green( `${chalk.green(
'✔' '✔'