summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/tty.js
diff options
context:
space:
mode:
authorMarvin Hagemeister <marvin@deno.com>2024-08-19 17:13:09 +0200
committerGitHub <noreply@github.com>2024-08-19 17:13:09 +0200
commit48701c19f8b2661c7e2cd997e62070d74baa86d0 (patch)
tree5c25a7f8c8d4b51fa7ed2475edb7a8f5ce5f417d /ext/node/polyfills/tty.js
parentc94c5cddb137069640fc9fc61435204d6f63fc5d (diff)
fix(node/tty): fix `tty.WriteStream.hasColor` with different args (#25094)
The check in `tty.WriteStream.prototype.hasColors()` was incorrect leading to the [`yoctocolors`](https://github.com/sindresorhus/yoctocolors) package not printing any colors. Fixes https://github.com/denoland/deno/issues/24407
Diffstat (limited to 'ext/node/polyfills/tty.js')
-rw-r--r--ext/node/polyfills/tty.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/node/polyfills/tty.js b/ext/node/polyfills/tty.js
index 2e8ecc8e1..e906c5f67 100644
--- a/ext/node/polyfills/tty.js
+++ b/ext/node/polyfills/tty.js
@@ -113,7 +113,10 @@ export class WriteStream extends Socket {
* @returns {boolean}
*/
hasColors(count, env) {
- if (env === undefined && typeof count === "object") {
+ if (
+ env === undefined &&
+ (count === undefined || typeof count === "object" && count !== null)
+ ) {
env = count;
count = 16;
}