-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
reporters/base: use supports-color to detect colorable term #1545
Conversation
LGTM if we fix the build errors. |
Looks like the problem is this line. Seems I'll see if I can have it support |
I think @dasilvacontin is right – the |
I would prefer using the caret character. Can't we just force a higher version of npm? Kinda what we ended up doing at mustache.js: janl/mustache.js#421 |
What do you prefer about the caret character?
Force-install a newer version of NPM? That's doable as long as it's compatible with that version of node. When was the caret character introduced? |
With the caret character, we will be getting both minor releases and patches/bugfixes. With the tilde, as soon as they do either a major or a minor release we will stop automatically getting patches and bugfixes. On a second look, it seems like the philosophy in mocha is manually updating dependencies, since a lot of people rely on this package for their tests. |
@@ -33,7 +34,7 @@ exports = module.exports = Base; | |||
* Enable coloring by default. | |||
*/ | |||
|
|||
exports.useColors = isatty || (process.env.MOCHA_COLORS !== undefined); | |||
exports.useColors = (isatty && supportsColor) || (process.env.MOCHA_COLORS !== undefined); |
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.
supportsColor
already checks if stdout is TTY, so I think the isatty
check could be dropped.
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.
Corrected.
This replaces #1497. Detecting whether a terminal is TTY is not enough to ensure that it can also support color. This module, supports-color, is a wholistic solution which captures the greatest range of possible terminals with the greatest accuracy. The module is extremely lightweight and does not represent a burdern to Mocha users.
Any reason you're not just using |
@sindresorhus discussed in #1330 and #1325. I'm still all in favor, especially considering we already use |
@sindresorhus, @jbnicolai, @dasilvacontin Re: fuzzy dependencies ( Would prefer to use |
Ok, this is starting to feel like a wild 🐦 chase. Chalk looks like a pretty big lift – completely reworking the way writing to the console happens. Am I correct in this assumption? |
@parkr yep, gonna merge this and we can talk about chalk somewhere else if necessary |
reporters/base: use supports-color to detect colorable term
Thank you! |
This replaces #1497.
Detecting whether a terminal is TTY is not enough
to ensure that it can also support color.
This module, supports-color, is a wholistic solution
which captures the greatest range of possible terminals
with the greatest accuracy. The module is extremely
lightweight and does not represent a burdern to Mocha
users.