diff --git a/src/CommandLine/Console.php b/src/CommandLine/Console.php index 51959b3..03eff0f 100644 --- a/src/CommandLine/Console.php +++ b/src/CommandLine/Console.php @@ -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' + ); } }