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 diff --git a/index.ts b/index.ts index 07c9261..d148c8e 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(" "); } @@ -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}'`; + execSync(commitCommand, {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); } }