Skip to content

Commit

Permalink
Detect CLI color support for Windows 10 build 10586
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati authored and nicolas-grekas committed Apr 4, 2016
1 parent cc38659 commit 1220da2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Output/StreamOutput.php
Expand Up @@ -85,7 +85,7 @@ protected function doWrite($message, $newline)
*
* Colorization is disabled if not supported by the stream:
*
* - Windows without Ansicon, ConEmu or Mintty
* - Windows before 10.0.10586 without Ansicon, ConEmu or Mintty
* - non tty consoles
*
* @return bool true if the stream supports colorization, false otherwise
Expand All @@ -94,7 +94,11 @@ protected function hasColorSupport()
{
// @codeCoverageIgnoreStart
if (DIRECTORY_SEPARATOR === '\\') {
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
return
0 >= version_compare('10.0.10586', PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD)
|| false !== getenv('ANSICON')
|| 'ON' === getenv('ConEmuANSI')
|| 'xterm' === getenv('TERM');
}

return function_exists('posix_isatty') && @posix_isatty($this->stream);
Expand Down

0 comments on commit 1220da2

Please sign in to comment.