Skip to content

Commit

Permalink
Fix console diff
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Oct 30, 2019
1 parent 492404a commit 7f3948c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions requirement-checker/expected_terminal_diff
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
> *
> * @license MIT (c) Fabien Potencier <fabien@symfony.com>
> */
113c120
122c129
< return [(int) $matches[2], (int) $matches[1]];
---
> return array((int) $matches[2], (int) $matches[1]);
137,140c144,147
146,149c153,156
< $descriptorspec = [
< 1 => ['pipe', 'w'],
< 2 => ['pipe', 'w'],
Expand All @@ -38,7 +38,7 @@
> 1 => array('pipe', 'w'),
> 2 => array('pipe', 'w'),
> );
142c149
151c158
< $process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
---
> $process = proc_open($command, $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
11 changes: 10 additions & 1 deletion requirement-checker/src/Terminal.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,21 @@ private static function initDimensions()
// or [w, h] from "wxh"
self::$width = (int) $matches[1];
self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
} elseif (self::hasSttyAvailable()) {
self::initDimensionsUsingStty();
} elseif (null !== $dimensions = self::getConsoleMode()) {
// extract [w, h] from "wxh"
self::$width = (int) $dimensions[0];
self::$height = (int) $dimensions[1];
}
} elseif ($sttyString = self::getSttyColumns()) {
} else {
self::initDimensionsUsingStty();
}
}

private static function initDimensionsUsingStty()
{
if ($sttyString = self::getSttyColumns()) {
if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
// extract [w, h] from "rows h; columns w;"
self::$width = (int) $matches[2];
Expand Down

0 comments on commit 7f3948c

Please sign in to comment.