From 7e5ed6de0ba1071e67202a261cf919802edb8130 Mon Sep 17 00:00:00 2001 From: di-sukharev Date: Sat, 1 Apr 2023 13:24:15 +0800 Subject: [PATCH] refactor(commit.ts): add push command when no remotes are found refactor(githook.ts): simplify switch statement by removing comments and adding inline comments --- src/commands/commit.ts | 6 ++++++ src/commands/githook.ts | 9 +++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/commands/commit.ts b/src/commands/commit.ts index 64faeea..4ca9709 100644 --- a/src/commands/commit.ts +++ b/src/commands/commit.ts @@ -79,6 +79,12 @@ ${chalk.grey('——————————————————')}` const remotes = await getGitRemotes(); + if (!remotes.length) { + const { stdout } = await execa('git', ['push']); + if (stdout) outro(stdout); + process.exit(0); + } + if (remotes.length === 1) { const isPushConfirmedByUser = await confirm({ message: 'Do you want to run `git push`?' diff --git a/src/commands/githook.ts b/src/commands/githook.ts index 152d6c6..ee3aec6 100755 --- a/src/commands/githook.ts +++ b/src/commands/githook.ts @@ -11,16 +11,13 @@ const platform = process.platform; let separator = ''; switch (platform) { - // Windows - case 'win32': + case 'win32': // Windows separator = path.sep; break; - // macOS - case 'darwin': + case 'darwin': // macOS separator = ''; break; - // Linux - case 'linux': + case 'linux': // Linux separator = ''; break; default: