2 parents f5f74e8 + 6885023 commit f4a060fCopy full SHA for f4a060f
2 files changed
src/Console/ConsoleOutput.php
@@ -175,6 +175,9 @@ public function __construct(string $stream = 'php://stdout')
175
(
176
function_exists('posix_isatty') &&
177
!posix_isatty($this->_output)
178
+ ) ||
179
+ (
180
+ env('NO_COLOR') !== null
181
)
182
) {
183
$this->_outputAs = self::PLAIN;
tests/TestCase/Console/ConsoleOutputTest.php
@@ -56,6 +56,15 @@ public function tearDown(): void
56
unset($this->output);
57
}
58
59
+ public function testNoColorEnvironmentVariable()
60
+ {
61
+ $_SERVER['NO_COLOR'] = '1';
62
+ $output = new ConsoleOutput();
63
+ $this->assertSame(ConsoleOutput::PLAIN, $output->getOutputAs());
64
+
65
+ unset($_SERVER['NO_COLOR']);
66
+ }
67
68
/**
69
* test writing with no new line
70
*
0 commit comments