Skip to content

Commit

Permalink
Fix: Clarify color option (fixes #5928) (#5974)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeber authored and nzakas committed Apr 28, 2016
1 parent e7e6581 commit 577757d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
9 changes: 5 additions & 4 deletions docs/user-guide/command-line-interface.md
Expand Up @@ -66,7 +66,7 @@ Handling warnings:
Output:
-o, --output-file path::String Specify file to write report to
-f, --format String Use a specific output format - default: stylish
--no-color Disable color in piped output
--color, --no-color Force enabling/disabling of color
Miscellaneous:
--init Run config initialization wizard - default: false
Expand Down Expand Up @@ -323,12 +323,13 @@ When specified, the given format is output to the console. If you'd like to save

This saves the output into the `results.txt` file.

#### `--no-color`
#### `--color`, `--no-color`

Disable color in piped output.
This option forces the enabling/disabling of colorized output. You can use this to override the default behavior, which is to enable colorized output unless no TTY is detected, such as when when piping `eslint` through `cat` or `less`.

Example:
Examples:

eslint --color file.js | cat
eslint --no-color file.js

### Miscellaneous
Expand Down
4 changes: 2 additions & 2 deletions lib/options.js
Expand Up @@ -173,8 +173,8 @@ module.exports = optionator({
{
option: "color",
type: "Boolean",
default: "true",
description: "Disable color in piped output"
alias: "no-color",
description: "Force enabling/disabling of color"
},
{
heading: "Miscellaneous"
Expand Down
8 changes: 7 additions & 1 deletion tests/lib/options.js
Expand Up @@ -190,11 +190,17 @@ describe("options", function() {
});

describe("--color", function() {
it("should return true for .color when passed", function() {
it("should return true for .color when passed --color", function() {
var currentOptions = options.parse("--color");

assert.isTrue(currentOptions.color);
});

it("should return false for .color when passed --no-color", function() {
var currentOptions = options.parse("--no-color");

assert.isFalse(currentOptions.color);
});
});

describe("--stdin", function() {
Expand Down

0 comments on commit 577757d

Please sign in to comment.