From 2d09b1b28dbeebcefc2e1b06b7e7a71f3c135bac Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Fri, 12 Jan 2024 22:47:47 -0800 Subject: [PATCH] Log error using console.error and in red for emphasis --- main.ts | 5 +++-- main_test.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/main.ts b/main.ts index a1d3442..9270ab0 100644 --- a/main.ts +++ b/main.ts @@ -71,8 +71,9 @@ export function main() { const words = parseInput(input); const factors = getLowerFactors(words.length); if (factors.length === 0) { - console.log( - `\nNo permutations found. Seed phrase of length ${words.length} can't be arranged into a grid.`, + console.error( + `%c\nNo permutations found. Seed phrase of length ${words.length} can't be arranged into a grid.`, + "color: red", ); Deno.exit(0); } diff --git a/main_test.ts b/main_test.ts index fd385d8..7ab078d 100644 --- a/main_test.ts +++ b/main_test.ts @@ -199,7 +199,7 @@ Deno.test("main logs permutations of a 12-word seed phrase", () => { }); Deno.test("main exits cleanly on a malformed seed phrase", () => { - const consoleSpy = spy(console, "log"); + const consoleSpy = spy(console, "error"); const promptStub = stub( globalThis, "prompt", @@ -207,7 +207,7 @@ Deno.test("main exits cleanly on a malformed seed phrase", () => { ); assertThrows(main); // Calling Deno.exit() within a test throws an error - assertSpyCalls(consoleSpy, 1); // console.log was called exactly 1 time + assertSpyCalls(consoleSpy, 1); // console.error was called exactly 1 time consoleSpy.restore(); promptStub.restore(); -- 2.47.3