-
Notifications
You must be signed in to change notification settings - Fork 3k
config: disable color by default when $NO_COLOR is set #19929
Conversation
lib/config/defaults.js
Outdated
@@ -130,7 +130,7 @@ Object.defineProperty(exports, 'defaults', {get: function () { | |||
|
|||
cidr: null, | |||
|
|||
color: true, | |||
color: typeof(process.env.NO_COLOR) === '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.
According to the error on CI, we might need to replace here with this: typeof process.env.NO_COLOR
.
Refs: https://github.com/eslint/eslint/blob/master/docs/rules/no-extra-parens.md
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.
This is better off as !process.env.NO_COLOR
or, if you want NO_COLOR=""
to be truthy, process.env.NO_COLOR != null
(with one =
)
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'm 👍 on this after a couple of review edits. Thanks for proposing this!
lib/config/defaults.js
Outdated
@@ -130,7 +130,7 @@ Object.defineProperty(exports, 'defaults', {get: function () { | |||
|
|||
cidr: null, | |||
|
|||
color: true, | |||
color: typeof(process.env.NO_COLOR) === '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.
This is better off as !process.env.NO_COLOR
or, if you want NO_COLOR=""
to be truthy, process.env.NO_COLOR != null
(with one =
)
doc/misc/npm-config.md
Outdated
@@ -278,7 +278,7 @@ This is a list of CIDR address to be used when configuring limited access tokens | |||
|
|||
### color | |||
|
|||
* Default: true | |||
* Default: true, unless the environment variable `NO_COLOR` is set |
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.
You can remove this. Please mention NO_COLOR
in the description below, instead, and how to use it. I'd rather keep this describing what the "no action" default is.
This makes npm follow the NO_COLOR standard, as explained in http://no-color.org/ > All command-line software which outputs text with ANSI color added > should check for the presence of a NO_COLOR environment variable that, > when present (regardless of its value), prevents the addition of ANSI > color. npm already provides environment variables (npm_config_color=false) and options (--no-color) to disable coloring by default, but NO_COLOR is an comprehensive approach to disable colors for all tools.
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.
Thanks for the changes! This looks great, and I'll be including it in this week's release! 🎉
This makes npm follow the NO_COLOR standard, as explained in http://no-color.org/ > All command-line software which outputs text with ANSI color added > should check for the presence of a NO_COLOR environment variable that, > when present (regardless of its value), prevents the addition of ANSI > color. npm already provides environment variables (npm_config_color=false) and options (--no-color) to disable coloring by default, but NO_COLOR is an comprehensive approach to disable colors for all tools. PR-URL: #19929 Credit: @chneukirchen Reviewed-By: @zkat
This makes npm follow the NO_COLOR standard, as explained in
http://no-color.org/
npm already provides environment variables (npm_config_color=false) and
options (--no-color) to disable coloring by default, but NO_COLOR is an
comprehensive approach to disable colors for all tools.