Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the color detection code from Symfony #138

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/Util/System/Windows.php
Expand Up @@ -69,6 +69,24 @@ protected function getDimensions()
*/
protected function systemHasAnsiSupport()
{
return (getenv('ANSICON') === true || getenv('ConEmuANSI') === 'ON');
if ('Hyper' === getenv('TERM_PROGRAM')) {
return true;
}
if (\DIRECTORY_SEPARATOR === '\\') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already know that this is running on windows. so everything outside this condition ( except the Hyper terminal check ) should be removed.

return (\function_exists('sapi_windows_vt100_support')
&& @sapi_windows_vt100_support(STDOUT))
|| false !== getenv('ANSICON')
|| 'ON' === getenv('ConEmuANSI')
|| 'xterm' === getenv('TERM');
}
if (\function_exists('stream_isatty')) {
return @stream_isatty(STDOUT);
}
if (\function_exists('posix_isatty')) {
return @posix_isatty(STDOUT);
}
$stat = @fstat(STDOUT);
// Check if formatted mode is S_IFCHR
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
}
}