From df9a129740df0bf1c09c9ec48b3b3dfc93856cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bedir=20Han=20Din=C3=A7?= Date: Mon, 11 Dec 2023 19:21:26 +0300 Subject: [PATCH 1/5] fix: Changed execSync into spawnSync (#7) --- index.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/index.ts b/index.ts index 07c9261..cc6a9fd 100644 --- a/index.ts +++ b/index.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node -import { execSync } from "child_process"; +import { execSync, spawnSync } from "child_process"; import enquirer from "enquirer"; import ora from "ora"; @@ -65,17 +65,21 @@ async function run(diff: string) { }); if (answer.message === CUSTOM_MESSAGE_OPTION) { - execSync("git commit", { stdio: "inherit" }); + execSync("git commit", {stdio: "inherit"}); return; } else { - execSync(`git commit -m '${escapeCommitMessage(answer.message)}'`, { - stdio: "inherit", - }); + const commitMessage = escapeCommitMessage(answer.message); + const commitCommand = ['git', 'commit', '-m', commitMessage]; + spawnSync(commitCommand[0], commitCommand.slice(1), {stdio: 'inherit'}); return; } } catch (e) { - console.log("Aborted."); - console.log(e); + console.log("Error:", e.message || e); + if (e.status !== null && e.status !== 0) { + console.error("Git commit failed with status code:", e.status); + } else { + console.error("Aborted."); + } process.exit(1); } } From ad240c8ff7ee16833ad8bd081b1c29502a7e0504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bedir=20Han=20Din=C3=A7?= Date: Mon, 11 Dec 2023 19:22:37 +0300 Subject: [PATCH 2/5] chore: Fixed typo where it says bug instead of big --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index cc6a9fd..7387544 100644 --- a/index.ts +++ b/index.ts @@ -41,7 +41,7 @@ async function run(diff: string) { // TODO: we should use a good tokenizer here const diffTokens = diff.split(" ").length; if (diffTokens > 2000) { - console.log(`Diff is way too bug. Truncating to 700 tokens. It may help`); + console.log(`Diff is way too big. Truncating to 700 tokens. It may help`); diff = diff.split(" ").slice(0, 700).join(" "); } From 348d8f8a3e5bf5c096b21da46b39b41fc559d76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bedir=20Han=20Din=C3=A7?= Date: Mon, 11 Dec 2023 19:23:25 +0300 Subject: [PATCH 3/5] chore: Fixed typo in readme (#39) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c2ef2a..4d3fd44 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ suggest 10 commit messages based on the following diff: {{diff}} commit messages should: - follow conventional commits - - message format should be: [scope]: + - message format should be: (scope): examples: - fix(authentication): add password regex pattern From 6485619a2a2eeec279c6361bce3af27c021d6e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bedir=20Han=20Din=C3=A7?= Date: Mon, 11 Dec 2023 20:28:11 +0300 Subject: [PATCH 4/5] refactor(index.ts): refactor spawnSync to execSync --- index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 7387544..bcc7090 100644 --- a/index.ts +++ b/index.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node -import { execSync, spawnSync } from "child_process"; +import { execSync } from "child_process"; import enquirer from "enquirer"; import ora from "ora"; @@ -69,8 +69,8 @@ async function run(diff: string) { return; } else { const commitMessage = escapeCommitMessage(answer.message); - const commitCommand = ['git', 'commit', '-m', commitMessage]; - spawnSync(commitCommand[0], commitCommand.slice(1), {stdio: 'inherit'}); + const commitCommand = `git commit -m "${commitMessage}"`; + execSync(commitCommand, {stdio: 'inherit'}); return; } } catch (e) { From 31ec08032ca9340798dd40b2f6c814cb0f2ff915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bedir=20Han=20Din=C3=A7?= Date: Tue, 12 Dec 2023 11:46:22 +0300 Subject: [PATCH 5/5] fix: Changed double quotes into single quote --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index bcc7090..d148c8e 100644 --- a/index.ts +++ b/index.ts @@ -69,7 +69,7 @@ async function run(diff: string) { return; } else { const commitMessage = escapeCommitMessage(answer.message); - const commitCommand = `git commit -m "${commitMessage}"`; + const commitCommand = `git commit -m '${commitMessage}'`; execSync(commitCommand, {stdio: 'inherit'}); return; }