Skip to content

Commit

Permalink
[PhpUnitBridge] Streamline ansi/no-ansi of composer according to phpu…
Browse files Browse the repository at this point in the history
…nit --colors option
  • Loading branch information
kick-the-bucket authored and nicolas-grekas committed Jun 18, 2020
1 parent ac355e1 commit 26c21b8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bin/simple-phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,21 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
}
}

if (in_array('--colors=never', $argv, true) || (isset($argv[$i = array_search('never', $argv, true) - 1]) && '--colors' === $argv[$i])) {
$COMPOSER .= ' --no-ansi';
} else {
$COMPOSER .= ' --ansi';
}

$info += array(
'versions' => array(),
'requires' => array('php' => '*'),
);

if (1 === \count($info['versions'])) {
$passthruOrFail("$COMPOSER create-project --ignore-platform-reqs --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi -s dev phpunit/phpunit phpunit-$PHPUNIT_VERSION \"$PHPUNIT_VERSION.*\"");
$passthruOrFail("$COMPOSER create-project --ignore-platform-reqs --no-install --prefer-dist --no-scripts --no-plugins --no-progress -s dev phpunit/phpunit phpunit-$PHPUNIT_VERSION \"$PHPUNIT_VERSION.*\"");
} else {
$passthruOrFail("$COMPOSER create-project --ignore-platform-reqs --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit phpunit-$PHPUNIT_VERSION \"$PHPUNIT_VERSION.*\"");
$passthruOrFail("$COMPOSER create-project --ignore-platform-reqs --no-install --prefer-dist --no-scripts --no-plugins --no-progress phpunit/phpunit phpunit-$PHPUNIT_VERSION \"$PHPUNIT_VERSION.*\"");
}

@copy("phpunit-$PHPUNIT_VERSION/phpunit.xsd", 'phpunit.xsd');
Expand Down Expand Up @@ -144,7 +150,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
$q = '\\' === DIRECTORY_SEPARATOR ? '"' : '';
// --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
$exit = proc_close(proc_open("$q$COMPOSER install --no-dev --prefer-dist --no-progress --ansi$q", array(), $p, getcwd()));
$exit = proc_close(proc_open("$q$COMPOSER install --no-dev --prefer-dist --no-progress$q", array(), $p, getcwd()));
putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
if ($exit) {
exit($exit);
Expand Down

0 comments on commit 26c21b8

Please sign in to comment.