Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  [PhpUnitBridge][VarDumper] fix color detection
  [CI] Make sure we preserve file->header when we run sync-translations.php
  Review validators.sl.xlf
  • Loading branch information
nicolas-grekas committed Feb 8, 2024
2 parents faaaa5e + 8ec305a commit cb3239f
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions Output/StreamOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ protected function hasColorSupport(): bool
return false;
}

if (!$this->isTty()) {
// Detect msysgit/mingw and assume this is a tty because detection
// does not work correctly, see https://github.com/composer/composer/issues/9690
if (!@stream_isatty($this->stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
return false;
}

Expand All @@ -120,21 +122,4 @@ protected function hasColorSupport(): bool
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
}

/**
* Checks if the stream is a TTY, i.e; whether the output stream is connected to a terminal.
*
* Reference: Composer\Util\Platform::isTty
* https://github.com/composer/composer
*/
private function isTty(): bool
{
// Detect msysgit/mingw and assume this is a tty because detection
// does not work correctly, see https://github.com/composer/composer/issues/9690
if (\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
return true;
}

return @stream_isatty($this->stream);
}
}

0 comments on commit cb3239f

Please sign in to comment.