-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add basic color detection #5
Conversation
Sorry, I was unclear. The todo comment should be in the code, not readme. |
Tests are failing. And thinking more about this, I think we should document the supported flags & env variables ( |
@sindresorhus The build is failing because Node.js is not detecting features on the GitHub Actions terminal that indicate color support. See the related |
I think that should be done regardless. |
I think a better fix would be to use |
Did you see ^? |
Maybe also worth doing a Node.js PR to document these things? |
@sindresorhus Also, this PR should be good to go. |
PR-URL: #40385 Refs: sindresorhus/yoctocolors#5 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: #40385 Refs: sindresorhus/yoctocolors#5 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
That's not the docs we are linking to in the readme though. And I think it's good to just document it here anyway for ease of discovery. |
Config errors caused the build to fail - fixed now. |
It is now a constant, not a function. Dependency-free detection. Credit to sindresorhus/yoctocolors#5
PR-URL: #40385 Refs: sindresorhus/yoctocolors#5 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
import tty from 'node:tty'; | ||
|
||
// TODO: Use a better method when it's added to Node.js (https://github.com/nodejs/node/pull/40240) | ||
const hasColors = tty.WriteStream.prototype.hasColors(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a reason for doing this instead of process.stdout.hasColors()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the answer is in the TODO comment. process.stdout.hasColors()
was not available then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed that.
Seems process.stdout.hasColors()
has been available. However, they're trying to deprecate it because:
- it's based on the environment rather than the stream
- it's not available when
process.stdout
is not a proper TTY
In the PR, they're trying to expose a standalone function but is blocked by deprecation strategy for the prototype method.
No description provided.