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
Improve the detections #98
Comments
It's awesome that it's now in Node.js. The problem is that the detection will be ever changing, so I don't think we'll ever be able to actually use the native methods as we favor stability over all Node.js versions we support. Imagine if the detection in Node.js core changes between each major version and we support 3 major versions in Chalk. That will create a bad experience for the user. Another reason I don't want to depend on the Node.js logic is that we can move faster while Node.js is locked into their major version schedule for breaking changes. I think the best way forward is to just improve our detection with inspiration from the Node.js logic.
That's not always a good thing. The more fine-grained cases you handle, the more assumption there are that could be broken at any time. |
getColorDepth()
core method
I'm gonna re-title this issue to be about improving the detection logic. |
@issuehunt has funded $60.00 to this issue.
|
@sindresorhus idk about you but I'd personally love to retire the argv sniffing we do in this package. |
@Qix- I don't think we should retire it, it's useful for the common case. Instead, we should also expose the detections without the flag logic, per #40 (comment). |
@sindresorhus It causes some annoyance when dealing with argument parsing, and I personally believe it's out of scope for the project. This module is to detect color support in the terminal with a potential environment variable override. Sniffing argv is pretty sacred IMO, and while I understand that might break some applications that rely on this it wouldn't be hard to migrate whatsoever. It might make sense to support an But as it stands, I think it's an artifact of feature creep since it's very intensely opinionated and non-specified. We're essentially dictating how the CLI of a program should look or behave, especially without a lot of users even knowing it. Not that we have any real metrics to support it, but I hypothesize that the vast majority of users that want to override the color support level use environment variables instead of command line flags. Just my $0.02. I think I left a comment elsewhere (I can't find it now) about how this would look programmatically with |
So I've since updated my views after looking at some of the PRs that went into Node's color depth "feature". The amount of thought and discussion that went into it was next to nothing. Their use of the term "depth" isn't even correct. Some of the PRs were merged even after someone objected with "perhaps we should standardize this". None of us at chalk were pinged - which I realize isn't a requirement, but a lot of the concerns and discussions that would have benefitted the implementation are those we've had time and time again with users, developers and terminal emulator implementors alike over almost a decade. That color depth method will probably break your code at some point, given how little thought and effort went into it. I'd highly recommend against using it. While this sounds like something we should support, there's too high of a chance this would cause headache in the future. It's really hard to remove a check gracefully, without breaking a lot of people, than it is to add it - and this would definitely cause problems later on. Thank you for the suggestion, it was a very good one but alas just didn't pan out :) |
getColorDepth()
was added in Node.js9.9.0
andhasColors()
andFORCE_COLOR=0|1|2|3
to Node.js11.13.0
. They are directly based on this module's code.supports-color
brings extra features:[--no]-color[s]
hasColors()
isundefined
ifstream.isTTY
is nottrue
, i.e. one needs to dostream.hasColors !== undefined && stream.hasColors()
On the other hand,
getColorDepth()
andhasColors()
:My question is: wouldn't it make sense to do the following?
getColorDepth()
andhasColors()
. Basically, just copy/pasting the code. If the Node.js running version supports those functions, they can be directly used. Those ponyfills could be removed in the future once Node.js supported versions are upgraded.IssueHunt Summary
Backers (Total: $60.00)
Become a backer now!
Or submit a pull request to get the deposits!
Tips
IssueHunt has been backed by the following sponsors. Become a sponsor
The text was updated successfully, but these errors were encountered: