From 1c113c2901d23c93823510097273282992d0bef4 Mon Sep 17 00:00:00 2001 From: di-sukharev Date: Tue, 28 Mar 2023 11:22:57 +0800 Subject: [PATCH] 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 --- src/commands/commit.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/commands/commit.ts b/src/commands/commit.ts index cc8eb13..b16ff95 100644 --- a/src/commands/commit.ts +++ b/src/commands/commit.ts @@ -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); -} \ No newline at end of file +}