From 04a7fe1a096df9b15f5e914ffa35bfb479cdedcc Mon Sep 17 00:00:00 2001 From: feywind <57276408+feywind@users.noreply.github.com> Date: Fri, 7 Mar 2025 15:50:45 -0500 Subject: [PATCH] fix: bypass colour checks when in browsers (or other non-Node-compatible runtimes) --- logging-utils/src/colours.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/logging-utils/src/colours.ts b/logging-utils/src/colours.ts index bd31ae85f..3fccf75e4 100644 --- a/logging-utils/src/colours.ts +++ b/logging-utils/src/colours.ts @@ -49,6 +49,7 @@ export class Colours { */ static isEnabled(stream: tty.WriteStream): boolean { return ( + stream && // May happen in browsers. stream.isTTY && (typeof stream.getColorDepth === 'function' ? stream.getColorDepth() > 2 @@ -57,7 +58,7 @@ export class Colours { } static refresh(): void { - Colours.enabled = Colours.isEnabled(process.stderr); + Colours.enabled = Colours.isEnabled(process?.stderr); if (!this.enabled) { Colours.reset = ''; Colours.bright = '';