-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Labels
Description
Version: Deno 2.1.3
I checked whether some new code I have written will work with Deno, and it doesn't. (By design my code fails gracefully and assumes color not available.) My high level goal with the code is checking whether it is appropriate to show color on stdout or stderr from a command-line application.
{
getOutHasColors: () =>
useColor() ?? (process.stdout.isTTY && process.stdout.hasColors?.()),
getErrHasColors: () =>
useColor() ?? (process.stderr.isTTY && process.stderr.hasColors?.()),
}I saw #24619 added tty.WriteStream.prototype.hasColors() and I can see that routine.
$ node
Welcome to Node.js v22.12.0.
Type ".help" for more information.
> process.stdout.isTTY
true
> process.stdout.hasColors()
true
>
$
$ deno
Deno 2.1.3
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> process.stdout.isTTY
true
> process.stdout.hasColors()
Uncaught TypeError: process.stdout.hasColors is not a function
at <anonymous>:1:37
> import tty from 'node:tty';
undefined
> tty?.WriteStream?.prototype?.isTTY
undefined
> tty?.WriteStream?.prototype?.hasColors?.()
true
>