From 56c886862cef8dd8cdc76ae460a98d26c5a2685c Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 26 Jul 2024 18:18:43 +0100 Subject: [PATCH] Add a newline character to the output of a file (#196) - Add a newline character at the end of the outputted file contents - This is so it follows POSIX convention #80 Reviewed-on: https://git.vylpes.xyz/RabbitLabs/random-bunny/pulls/196 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- src/helpers/cliHelper.ts | 2 +- tests/helpers/cliHelper.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/cliHelper.ts b/src/helpers/cliHelper.ts index 2776f2e..f4f5c63 100644 --- a/src/helpers/cliHelper.ts +++ b/src/helpers/cliHelper.ts @@ -9,7 +9,7 @@ export default class CliHelper { const output = OutputHelper.GenerateOutput(response, options); if (options.o) { - writeFileSync(options.o, output); + writeFileSync(options.o, `${output}\n`); } else { console.log(output); } diff --git a/tests/helpers/cliHelper.test.ts b/tests/helpers/cliHelper.test.ts index 3ea6687..0deb946 100644 --- a/tests/helpers/cliHelper.test.ts +++ b/tests/helpers/cliHelper.test.ts @@ -35,7 +35,7 @@ describe("Endpoint", () => { expect(OutputHelper.GenerateOutput).toHaveBeenCalledWith(response, options); expect(fs.writeFileSync).toHaveBeenCalledTimes(1); - expect(fs.writeFileSync).toHaveBeenCalledWith("file.txt", "test output"); + expect(fs.writeFileSync).toHaveBeenCalledWith("file.txt", "test output\n"); expect(console.log).not.toHaveBeenCalled();