Skip to content

Commit be7811d

Browse files
authored
fix: bypass colour checks when in browsers (or other non-Node-compatible runtimes) (#1725)
This fixes the problem that causes gax's CI tests to fail in browser mode.
1 parent f41a86b commit be7811d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

logging-utils/src/colours.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class Colours {
4949
*/
5050
static isEnabled(stream: tty.WriteStream): boolean {
5151
return (
52+
stream && // May happen in browsers.
5253
stream.isTTY &&
5354
(typeof stream.getColorDepth === 'function'
5455
? stream.getColorDepth() > 2
@@ -57,7 +58,7 @@ export class Colours {
5758
}
5859

5960
static refresh(): void {
60-
Colours.enabled = Colours.isEnabled(process.stderr);
61+
Colours.enabled = Colours.isEnabled(process?.stderr);
6162
if (!this.enabled) {
6263
Colours.reset = '';
6364
Colours.bright = '';

0 commit comments

Comments
 (0)