From 3280c0e2d190246b2baabc4fcf9b81bb680d7f9d Mon Sep 17 00:00:00 2001 From: Hassan El Mghari Date: Sun, 12 Feb 2023 00:18:05 -0500 Subject: [PATCH] Update aiCommit to use the cleaned up version and commit to git --- aicommit.mjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aicommit.mjs b/aicommit.mjs index 40ae8f4..dc10cbf 100644 --- a/aicommit.mjs +++ b/aicommit.mjs @@ -35,11 +35,12 @@ const response = await fetch("https://api.openai.com/v1/completions", { const json = await response.json(); const aiCommit = json.choices[0].text; +let cleanedUpAiCommit = aiCommit.replace(/(\r\n|\n|\r)/gm, ""); -echo(aiCommit); +echo(cleanedUpAiCommit); let confirmationMessage = await question( - "\nWould you like to use this commit message? " + chalk.yellow("(Y/n) "), + "\nWould you like to use this commit message? " + chalk.yellow("(Y/n) \n"), { choices: ["Y", "n"], } @@ -48,5 +49,5 @@ let confirmationMessage = await question( $.verbose = true; if (confirmationMessage !== "n") { - await $`git commit -m ${aiCommit}`; + await $`git commit -m ${cleanedUpAiCommit}`; }