10000 [PhpUnitBridge][VarDumper] fix color detection · symfony/console@8ec305a · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ec305a

Browse files
xabbuhnicolas-grekas
authored andcommitted
[PhpUnitBridge][VarDumper] fix color detection
1 parent f5436ad commit 8ec305a

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

Output/StreamOutput.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ protected function hasColorSupport()
9595
return false;
9696
}
9797

98-
if (!$this->isTty()) {
98+
// Detect msysgit/mingw and assume this is a tty because detection
99+
// does not work correctly, see https://github.com/composer/composer/issues/9690
100+
if (!@stream_isatty($this->stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
99101
return false;
100102
}
101103

@@ -118,21 +120,4 @@ protected function hasColorSupport()
118120
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
119121
return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
120122
}
121-
122-
/**
123-
* Checks if the stream is a TTY, i.e; whether the output stream is connected to a terminal.
124-
*
125-
* Reference: Composer\Util\Platform::isTty
126-
* https://github.com/composer/composer
127-
*/
128-
private function isTty(): bool
129-
{
130-
// Detect msysgit/mingw and assume this is a tty because detection
131-
// does not work correctly, see https://github.com/composer/composer/issues/9690
132-
if (\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
133-
return true;
134-
}
135-
136-
return @stream_isatty($this->stream);
137-
}
138123
}

0 commit comments

Comments
 (0)
0