From caa64fbcf974ffdee8f09785e5d816227bcc9b33 Mon Sep 17 00:00:00 2001 From: di-sukharev Date: Thu, 9 Mar 2023 13:58:27 +0800 Subject: [PATCH] * refactor(prepare-commit-msg-hook.ts): change appendFile to writeFile to write commit message to file * chore(prepare-commit-msg-hook.ts): add newline character before appending file content to commit message --- src/commands/prepare-commit-msg-hook.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands/prepare-commit-msg-hook.ts b/src/commands/prepare-commit-msg-hook.ts index a8f3c71..f5caef6 100644 --- a/src/commands/prepare-commit-msg-hook.ts +++ b/src/commands/prepare-commit-msg-hook.ts @@ -37,8 +37,12 @@ export const prepareCommitMessageHook = async () => { if (typeof commitMessage !== 'string') throw new Error(commitMessage.error); - // TODO: change to read file > write file with commitMessage - await fs.appendFile(messageFilePath, commitMessage); + const fileContent = await fs.readFile(messageFilePath); + + await fs.writeFile( + messageFilePath, + commitMessage + '\n' + fileContent.toString() + ); outro(`${chalk.green('✔')} commit done`); } catch (error) {