From: Ardis Lu Date: Sat, 13 Jan 2024 06:47:47 +0000 (-0800) Subject: Log error using console.error and in red for emphasis X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=2d09b1b28dbeebcefc2e1b06b7e7a71f3c135bac;p=seed-phrase-transposer Log error using console.error and in red for emphasis --- 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();