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 <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #40385 Refs: sindresorhus/yoctocolors#5 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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 <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
| 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.
Was there a reason for doing this instead of process.stdout.hasColors()?
There was a problem hiding this comment.
I don't remember.
There was a problem hiding this comment.
I believe the answer is in the TODO comment. process.stdout.hasColors() was not available then.
There was a problem hiding this comment.
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.stdoutis 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.