Add support for NO_COLOR env var

This commit is contained in:
Jordi Boggiano 2019-11-06 11:22:37 +01:00
parent 585c0df909
commit c1b0a8e956
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
5 changed files with 17 additions and 0 deletions

View File

@ -357,6 +357,11 @@ class DeprecationErrorHandler
return false;
}
// Follow https://no-color.org/
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
return false;
}
if ('Hyper' === getenv('TERM_PROGRAM')) {
return true;
}

View File

@ -13,6 +13,7 @@ CHANGELOG
* deprecated returning `null` from `Command::execute()`, return `0` instead
* Deprecated the `Application::renderException()` and `Application::doRenderException()` methods,
use `renderThrowable()` and `doRenderThrowable()` instead.
* added support for the `NO_COLOR` env var (https://no-color.org/)
4.3.0
-----

View File

@ -97,6 +97,11 @@ class StreamOutput extends Output
*/
protected function hasColorSupport()
{
// Follow https://no-color.org/
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
return false;
}
if ('Hyper' === getenv('TERM_PROGRAM')) {
return true;
}

View File

@ -10,6 +10,7 @@ CHANGELOG
* added the stamps of a message after it is dispatched in `TraceableMessageBus` and `MessengerDataCollector` collected data
* added `UuidCaster`
* made all casters final
* added support for the `NO_COLOR` env var (https://no-color.org/)
4.3.0
-----

View File

@ -582,6 +582,11 @@ class CliDumper extends AbstractDumper
return false;
}
// Follow https://no-color.org/
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
return false;
}
if ('Hyper' === getenv('TERM_PROGRAM')) {
return true;
}