File tree 1 file changed +11
-3
lines changed
src/Symfony/Component/Console/Output
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -81,17 +81,25 @@ protected function doWrite($message, $newline)
81
81
*
82
82
* Colorization is disabled if not supported by the stream:
83
83
*
84
- * - Windows != 10.0.10586 without Ansicon, ConEmu or Mintty
84
+ * - the stream is redirected (eg php file.php >log)
85
+ * - Windows without VT100 support, Ansicon, ConEmu, Mintty
85
86
* - non tty consoles
86
87
*
87
88
* @return bool true if the stream supports colorization, false otherwise
88
89
*/
89
90
protected function hasColorSupport ()
90
91
{
92
+ if (function_exists ('stream_isatty ' ) && !@stream_isatty ($ this ->stream )) {
93
+ return false ;
94
+ }
91
95
if (DIRECTORY_SEPARATOR === '\\' ) {
96
+ if (function_exists ('sapi_windows_vt100_support ' )) {
97
+ $ vt100Enabled = @sapi_windows_vt100_support ($ this ->stream );
98
+ } else {
99
+ $ vt100Enabled = '10.0.10586 ' === PHP_WINDOWS_VERSION_MAJOR .'. ' .PHP_WINDOWS_VERSION_MINOR .'. ' .PHP_WINDOWS_VERSION_BUILD ;
100
+ }
92
101
return
93
- function_exists ('sapi_windows_vt100_support ' ) && @sapi_windows_vt100_support ($ this ->stream )
94
- || '10.0.10586 ' === PHP_WINDOWS_VERSION_MAJOR .'. ' .PHP_WINDOWS_VERSION_MINOR .'. ' .PHP_WINDOWS_VERSION_BUILD
102
+ $ vt100Enabled
95
103
|| false !== getenv ('ANSICON ' )
96
104
|| 'ON ' === getenv ('ConEmuANSI ' )
97
105
|| 'xterm ' === getenv ('TERM ' );
You can’t perform that action at this time.
0 commit comments