diff --git a/index.ts b/index.ts index 3c24dea..9915d8c 100644 --- a/index.ts +++ b/index.ts @@ -611,14 +611,11 @@ async function showMenu(): Promise { if (selected === null || selected === BACK) return; - const result = - selected === "commit" - ? await handleCommit(false, false) - : selected === "pr" - ? await handlePR(false) - : await handleConfig(); + if (selected === "commit") await handleCommit(false, false); + else if (selected === "pr") await handlePR(false); + else await handleConfig(); - if (result !== "back") return; + return; } } @@ -663,8 +660,9 @@ async function handleCommit( const unstagedFiles = await getUnstagedFiles(); if (stagedFiles.length === 0 && unstagedFiles.length === 0) { - console.log(" Nothing to commit."); - return "done"; + console.log(`\n ${YELLOW}Nothing to commit.${RESET}`); + await ask(` ${DIM}Press Enter to exit...${RESET}`); + process.exit(0); } if (unstagedFiles.length > 0) { @@ -687,8 +685,9 @@ async function handleCommit( const diff = await getStagedDiff(); if (!diff) { - console.log(" No staged changes to commit."); - return "done"; + console.log(`\n ${YELLOW}No staged changes to commit.${RESET}`); + await ask(` ${DIM}Press Enter to exit...${RESET}`); + process.exit(0); } const MAX_DIFF_SIZE = 15000; @@ -817,9 +816,10 @@ async function handlePR(draft: boolean): Promise<"done" | "back"> { if (commits.length === 0) { console.error( - ` ${RED}Error: No commits on ${branchName} compared to ${baseBranch}. Commit something first.${RESET}`, + `\n ${YELLOW}No commits on ${branchName} compared to ${baseBranch}. Commit something first.${RESET}`, ); - process.exit(1); + await ask(` ${DIM}Press Enter to exit...${RESET}`); + process.exit(0); } console.log(