-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use process.stdout.isTTY instead of node:tty #100
Comments
What's the minimum Node version needed to run this? |
We would be able to use it in the browser? Like this 👇 https://svelte.dev/repl/032bb6cf5c0043a093e6c2a081c1957d?version=4.2.1 |
Just by making this change we could use Colorette in the browser? How would that work? |
Also, this would allow us to use it in Edge Runtimes. I'm using Next.js, and it is reporting something like this on the build.
Using the patch-package with this patch seems to work fine patches/colorette+2.0.20.patch diff --git a/node_modules/colorette/index.js b/node_modules/colorette/index.js
index 0d64e6b..a6ab8d1 100644
--- a/node_modules/colorette/index.js
+++ b/node_modules/colorette/index.js
@@ -1,5 +1,3 @@
-import * as tty from "tty"
-
const {
env = {},
argv = [],
@@ -10,9 +8,7 @@ const isDisabled = "NO_COLOR" in env || argv.includes("--no-color")
const isForced = "FORCE_COLOR" in env || argv.includes("--color")
const isWindows = platform === "win32"
const isDumbTerminal = env.TERM === "dumb"
-
-const isCompatibleTerminal =
- tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal
+const isCompatibleTerminal = process.stdout?.isTTY && env.TERM && !isDumbTerminal
const isCI =
"CI" in env && |
Cool! Want to send me a PR @iamandrewluca? |
@jorgebucaran here it is #103 |
https://nodejs.org/api/tty.html#tty
colorette/index.js
Line 1 in 20fc196
colorette/index.js
Line 15 in 20fc196
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 justimport ... from "./node_modules/colorette/index.js"
The text was updated successfully, but these errors were encountered: