File tree Expand file tree Collapse file tree 1 file changed +28
-9
lines changed Expand file tree Collapse file tree 1 file changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -129,19 +129,38 @@ public static function supportColor(): bool
129129 */
130130 public static function isSupportColor (): bool
131131 {
132- if (DIRECTORY_SEPARATOR === '\\' ) {
133- return '10.0.10586 ' === PHP_WINDOWS_VERSION_MAJOR . '. ' . PHP_WINDOWS_VERSION_MINOR . '. ' . PHP_WINDOWS_VERSION_BUILD ||
134- false !== getenv ('ANSICON ' ) ||
135- 'ON ' === getenv ('ConEmuANSI ' ) ||
136- 'xterm ' === getenv ('TERM ' )// || 'cygwin' === getenv('TERM')
137- ;
132+ // Follow https://no-color.org/
133+ if (isset ($ _SERVER ['NO_COLOR ' ]) || false !== getenv ('NO_COLOR ' )) {
134+ return false ;
138135 }
139136
140- if (!defined ('STDOUT ' )) {
141- return false ;
137+ // COLORTERM=truecolor
138+ $ colorTerm = getenv ('COLORTERM ' );
139+ if ('truecolor ' === $ colorTerm ) {
140+ return true ;
141+ }
142+
143+ // speical terminal
144+ $ termProgram = getenv ('TERM_PROGRAM ' );
145+ if ('Hyper ' === $ termProgram || 'Terminus ' === $ termProgram ) {
146+ return true ;
147+ }
148+
149+ $ stream = STDOUT ;
150+ if (\DIRECTORY_SEPARATOR === '\\' ) {
151+ return (\function_exists ('sapi_windows_vt100_support ' )
152+ && @sapi_windows_vt100_support ($ stream ))
153+ || false !== getenv ('ANSICON ' )
154+ || 'ON ' === getenv ('ConEmuANSI ' )
155+ || 'xterm ' === getenv ('TERM ' );
156+ }
157+
158+ // PHP 7 >= 7.2.0
159+ if (function_exists ('stream_isatty ' )) {
160+ return \stream_isatty ($ stream );
142161 }
143162
144- return self ::isInteractive (STDOUT );
163+ return self ::isInteractive ($ stream );
145164 }
146165
147166 /**
You can’t perform that action at this time.
0 commit comments