Skip to content

Commit

Permalink
updated detectColors()
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Dec 12, 2022
1 parent f0a96d7 commit ff1ba48
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/CommandLine/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,11 @@ public function color(?string $color, ?string $s = null): string
public static function detectColors(): bool
{
return (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg')
&& stream_isatty(STDOUT)
&& getenv('NO_COLOR') === false // https://no-color.org
&& (defined('PHP_WINDOWS_VERSION_BUILD')
? (function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(STDOUT))
|| getenv('ConEmuANSI') === 'ON' // ConEmu
|| getenv('ANSICON') !== false // ANSICON
|| getenv('term') === 'xterm' // MSYS
|| getenv('term') === 'xterm-256color' // MSYS
: true);
&& (getenv('FORCE_COLOR')
|| (function_exists('sapi_windows_vt100_support')
? sapi_windows_vt100_support(STDOUT)
: @stream_isatty(STDOUT)) // @ may trigger error 'cannot cast a filtered stream on this system'
);
}
}

0 comments on commit ff1ba48

Please sign in to comment.