Skip to content

Commit

Permalink
refactor(commit.ts): remove redundant spinner usage and replace with …
Browse files Browse the repository at this point in the history
…outro for push confirmation messages
  • Loading branch information
matscube committed Aug 22, 2024
1 parent eb3be62 commit 4b35672
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/commands/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,30 @@ ${chalk.grey('β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”')}`
if (config?.OCO_GITPUSH === false)
return

intro('opencommit - git push');

if (!remotes.length) {
const { stdout } = await execa('git', ['push']);
if (stdout) outro(stdout);
process.exit(0);
}


if (remotes.length === 1 && config?.OCO_GITPUSH !== true) {
const isPushConfirmedByUser = await confirm({
message: 'Do you want to run `git push`?'
});

if (isPushConfirmedByUser && !isCancel(isPushConfirmedByUser)) {
const pushSpinner = spinner();

pushSpinner.start(`Running 'git push ${remotes[0]}'`);
outro(`Running 'git push ${remotes[0]}' ...`);

const { stdout } = await execa('git', [
'push',
'--verbose',
remotes[0]
]);

pushSpinner.stop(
outro(
`${chalk.green('βœ”')} Successfully pushed all commits to ${
remotes[0]
}`
Expand All @@ -139,13 +140,12 @@ ${chalk.grey('β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”')}`
})) as string;

if (!isCancel(selectedRemote)) {
const pushSpinner = spinner();

pushSpinner.start(`Running 'git push ${selectedRemote}'`);
outro(`Running 'git push ${selectedRemote}' ...`);

const { stdout } = await execa('git', ['push', selectedRemote]);

pushSpinner.stop(
outro(
`${chalk.green(
'βœ”'
)} Successfully pushed all commits to ${selectedRemote}`
Expand Down

0 comments on commit 4b35672

Please sign in to comment.