-
-
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
Removed MOCHA_COLORS environment variable #3665
Conversation
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.
LGTM, thanks.
Wait. I don't think we should merge this. Can we instead detect the use of |
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.
please see my comment about deprecation
AFAICT, "migration" looks like replacing use of Here's an example of For whatever reason we never bothered to do this in our own CI, but there you go. |
(The reason why we never bothered to do this is that it interferes w/ our integration tests, apparently.) |
We could even go ahead and print the deprecation notice, then remove |
…vironment and set FORCE_COLOR=1
I think it will be good if we show the deprecation message and then remove |
Far less invasive would be to check for |
As we've had an issue with environment come up twice within a year, also think we should document our officially supported environment. Also provide notice that any envvar not officially documented should be considered an implementation detail and subject to change without warning. |
lib/reporters/base.js
Outdated
|
||
if (process.env.MOCHA_COLORS) { | ||
utils.deprecate( | ||
'"MOCHA_COLORS" is deprecated and will be removed from a future version of Mocha. Use "FORCE_COLOR" instead.' |
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.
Uh, you already removed it...
utils.deprecate(
'Support for deprecated "MOCHA_COLORS" environment variable was removed from Mocha. Use "FORCE_COLOR" instead.');
lib/reporters/base.js
Outdated
'"MOCHA_COLORS" is deprecated and will be removed from a future version of Mocha. Use "FORCE_COLOR" instead.' | ||
); | ||
delete process.env.MOCHA_COLORS; | ||
process.env.FORCE_COLOR = 1; |
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.
Environment variables should always be strings...
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.
But this is a rather heavy-handed approach...
lib/reporters/base.js
Outdated
); | ||
delete process.env.MOCHA_COLORS; | ||
process.env.FORCE_COLOR = 1; | ||
} |
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.
Think all deprecation-related code belongs here instead, prior to yargs
processing, so --colors
can be handled upfront.
Thanks, @plroebuck for reviewing the changes. Also If I conclude from your review comments, I shoud write the below code in if (process.env.MOCHA_COLORS) {
utils.deprecate(
'Support for deprecated "MOCHA_COLORS" environment variable was removed from Mocha. Use "FORCE_COLOR" instead.');
if (argv.indexOf('--colors') < 0 && argv.indexOf('-c') < 0) {
argv.push('--colors');
}
delete process.env.MOCHA_COLORS;
} Let me know, if anything needs to change |
Approved version prior to boneskull's request for deprecation notice
Added code to show deprication message of |
UPDATE: I can confirm that |
yes, @boneskull. |
OK, I don't think we should do this at all actually. I've spent another 30m or so looking at this, and it's a rabbit hole.
|
@waseemahmad31 I apologize for the confusion here. |
Mea culpa. I wrote "append", but meant "prepend"
Potential future maintenance nightmare, given the effort to remove this single redundant envvar. |
It's not usually trivial to remove things from Mocha, no. @waseemahmad31 Thanks for your effort on this |
@boneskull, @plroebuck thanks for the feedback. Initially, it seems like the easy one to start the first contribution. Anyway thanks for the detailed analysis of the impact of this change. |
Description of the Change
Remove MOCHA_COLORS environment variable
Why should this be in core?
The supports-color module's environment variable
FORCE_COLOR
provides the same functionality.Benefits
Redundant. One less thing to maintain.
Applicable issues
Fixes #3641
patch release