Skip to content

Use process.stdout.isTTY instead of node:tty #100

Open
@jcbhmr

Description

The preferred method of determining whether Node.js is being run within a TTY context is to check that the value of the process.stdout.isTTY property is true:

$ node -p -e "Boolean(process.stdout.isTTY)"
true
$ node -p -e "Boolean(process.stdout.isTTY)" | cat
false

https://nodejs.org/api/tty.html#tty

import * as tty from "tty"

tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal

globalThis.process?.stdout?.isTTY && env.TERM && !isDumbTerminal 

This would also remove the dependency on the node:tty module and make it "more easier" for use in the browser. i.e. NO TRANSPILATION required, you can just import ... from "./node_modules/colorette/index.js"

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions