Skip to content

Commit 97577ae

Browse files
feature #34252 [Console] Add support for NO_COLOR env var (Seldaek)
This PR was merged into the 4.4 branch. Discussion ---------- [Console] Add support for NO_COLOR env var | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | License | MIT | Doc PR | Adds support for https://no-color.org/ - ideally this would be considered a bugfix and added to older releases IMO, but submitting as new feature for now. cc @johnstevenson Commits ------- c1b0a8e Add support for NO_COLOR env var
2 parents 57e9b81 + c1b0a8e commit 97577ae

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ private static function hasColorSupport()
357357
return false;
358358
}
359359

360+
// Follow https://no-color.org/
361+
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
362+
return false;
363+
}
364+
360365
if ('Hyper' === getenv('TERM_PROGRAM')) {
361366
return true;
362367
}

src/Symfony/Component/Console/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ CHANGELOG
1313
* deprecated returning `null` from `Command::execute()`, return `0` instead
1414
* Deprecated the `Application::renderException()` and `Application::doRenderException()` methods,
1515
use `renderThrowable()` and `doRenderThrowable()` instead.
16+
* added support for the `NO_COLOR` env var (https://no-color.org/)
1617

1718
4.3.0
1819
-----

src/Symfony/Component/Console/Output/StreamOutput.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ protected function doWrite($message, $newline)
9797
*/
9898
protected function hasColorSupport()
9999
{
100+
// Follow https://no-color.org/
101+
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
102+
return false;
103+
}
104+
100105
if ('Hyper' === getenv('TERM_PROGRAM')) {
101106
return true;
102107
}

src/Symfony/Component/VarDumper/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CHANGELOG
1010
* added the stamps of a message after it is dispatched in `TraceableMessageBus` and `MessengerDataCollector` collected data
1111
* added `UuidCaster`
1212
* made all casters final
13+
* added support for the `NO_COLOR` env var (https://no-color.org/)
1314

1415
4.3.0
1516
-----

src/Symfony/Component/VarDumper/Dumper/CliDumper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,11 @@ private function hasColorSupport($stream): bool
582582
return false;
583583
}
584584

585+
// Follow https://no-color.org/
586+
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
587+
return false;
588+
}
589+
585590
if ('Hyper' === getenv('TERM_PROGRAM')) {
586591
return true;
587592
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy