Skip to content

Commit a444f0d

Browse files
swissspidyclaude
andcommitted
Turn color off explicitly in the linter runner under NO_COLOR
Dropping --colors left php-parallel-lint at its default autodetection, which only asks whether STDOUT is a terminal -- php-console-color has no NO_COLOR handling of its own. So NO_COLOR=1 composer lint still printed escape sequences interactively, while the other three runners disabled color outright. --no-colors has been available since v1.3, so this is the same one-flag treatment the PHPUnit, PHPStan and Behat runners already get. The README described the old behavior, which contradicted the no-color.org convention it cites; it now says what the runners do. The two bullets also pick up the list marker used everywhere else in the file. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GjJi6F76YZBt7cRrvXS6s6
1 parent debfc35 commit a444f0d

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎.readme-partials/USING.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ this package's `package.json`, which exists only to hold that pin.
208208

209209
Two environment variables make the test tools less chatty. Both are unset by default, which leaves the output exactly as it has always been.
210210

211-
- `NO_COLOR` (the [no-color.org](https://no-color.org/) convention) stops the runners from forcing ANSI color codes on, and leaves the decision to each tool's own terminal detection. Set this when capturing output to a file or a pipe, where the escape sequences are noise.
212-
- `WP_CLI_TEST_QUIET` switches the reporters to their most compact form: PHP_CodeSniffer reports one `file:line:col` line per violation with no progress ticker, PHPStan reports one `file:line:message` line per error with no progress bar and no result table. Behat's own output is already minimal, so it is unaffected.
211+
* `NO_COLOR` (the [no-color.org](https://no-color.org/) convention) turns off the ANSI color codes in the output of every runner. Set this when capturing output to a file or a pipe, where the escape sequences are noise.
212+
* `WP_CLI_TEST_QUIET` switches the reporters to their most compact form: PHP_CodeSniffer reports one `file:line:col` line per violation with no progress ticker, PHPStan reports one `file:line:message` line per error with no progress bar and no result table. Behat's own output is already minimal, so it is unaffected.
213213
214214
`NO_COLOR` also covers the Gherkin linter, which colors its report unconditionally and has no plain output format of its own.
215215

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ this package's `package.json`, which exists only to hold that pin.
219219

220220
Two environment variables make the test tools less chatty. Both are unset by default, which leaves the output exactly as it has always been.
221221

222-
- `NO_COLOR` (the [no-color.org](https://no-color.org/) convention) stops the runners from forcing ANSI color codes on, and leaves the decision to each tool's own terminal detection. Set this when capturing output to a file or a pipe, where the escape sequences are noise.
223-
- `WP_CLI_TEST_QUIET` switches the reporters to their most compact form: PHP_CodeSniffer reports one `file:line:col` line per violation with no progress ticker, PHPStan reports one `file:line:message` line per error with no progress bar and no result table. Behat's own output is already minimal, so it is unaffected.
222+
* `NO_COLOR` (the [no-color.org](https://no-color.org/) convention) turns off the ANSI color codes in the output of every runner. Set this when capturing output to a file or a pipe, where the escape sequences are noise.
223+
* `WP_CLI_TEST_QUIET` switches the reporters to their most compact form: PHP_CodeSniffer reports one `file:line:col` line per violation with no progress ticker, PHPStan reports one `file:line:message` line per error with no progress bar and no result table. Behat's own output is already minimal, so it is unaffected.
224224
225225
`NO_COLOR` also covers the Gherkin linter, which colors its report unconditionally and has no plain output format of its own.
226226

‎bin/run-linter-tests‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/bin/sh
22

3-
# Honor the NO_COLOR convention (https://no-color.org/) by leaving the color
4-
# decision to the tool's own TTY detection instead of forcing it.
3+
# Honor the NO_COLOR convention (https://no-color.org/). This has to turn the
4+
# color off explicitly rather than omit the flag, because the tool's own
5+
# detection only asks whether STDOUT is a terminal and knows nothing about
6+
# NO_COLOR, so an interactive run would still be colored.
57
COLOR_ARGS="--colors"
68
if [ -n "${NO_COLOR}" ]; then
7-
COLOR_ARGS=""
9+
COLOR_ARGS="--no-colors"
810
fi
911

1012
# shellcheck disable=SC2086 # Intentional word splitting of the optional arguments.

0 commit comments

Comments
 (0)