Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/system/supports-colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ module.exports = (function () {
return false;
}

if (argv.indexOf('--color') !== -1 ||
argv.indexOf('--color=true') !== -1 ||
argv.indexOf('--color=always') !== -1) {
if (!argv.indexOf('--no-color') !== -1 ||
!argv.indexOf('--color=false') !== -1) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong for multiple reasons.

  1. The || is an or, which means this will always enable color when either the first or the second argument is missing. This is always the case, except when you specify both arguments, which does not make much sense. I assume this was meant to be an &&.
  2. With an && this is the exact inverse of the if above. Which means all the code below this second if can never be reached.

Look at the code below. The issue you are experiencing may be hidden there.

I suggest to close this patch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi this was just a copy of the above code except from I added ! so if --no-color is used color is disabled if it is not used then color is enabled by default.

Copy link
Copy Markdown

@thiemowmde thiemowmde Apr 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how you invert a logical condition. I already described it in detail above.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!argv.indexOf('--no-color') is always a boolean, so it never equals -1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks, your right I looked below and found this pull #154 which fixed it.

return true;
}

Expand All @@ -58,4 +57,4 @@ module.exports = (function () {
}

return false;
})();
})();