comparison core/lib/Drupal/Core/Composer/Composer.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
4 4
5 use Drupal\Component\PhpStorage\FileStorage; 5 use Drupal\Component\PhpStorage\FileStorage;
6 use Composer\Script\Event; 6 use Composer\Script\Event;
7 use Composer\Installer\PackageEvent; 7 use Composer\Installer\PackageEvent;
8 use Composer\Semver\Constraint\Constraint; 8 use Composer\Semver\Constraint\Constraint;
9 use Composer\Util\ProcessExecutor;
9 10
10 /** 11 /**
11 * Provides static functions for composer script events. 12 * Provides static functions for composer script events.
12 * 13 *
13 * @see https://getcomposer.org/doc/articles/scripts.md 14 * @see https://getcomposer.org/doc/articles/scripts.md
158 // There is nothing to do. The user is probably installing using the 159 // There is nothing to do. The user is probably installing using the
159 // --no-dev flag. 160 // --no-dev flag.
160 return; 161 return;
161 } 162 }
162 163
163 // If the PHP version is 7.2 or above and PHPUnit is less than version 6 164 // If the PHP version is 7.0 or above and PHPUnit is less than version 6
164 // call the drupal-phpunit-upgrade script to upgrade PHPUnit. 165 // call the drupal-phpunit-upgrade script to upgrade PHPUnit.
165 if (!static::upgradePHPUnitCheck($phpunit_package->getVersion())) { 166 if (!static::upgradePHPUnitCheck($phpunit_package->getVersion())) {
166 $event->getComposer() 167 $event->getComposer()
167 ->getEventDispatcher() 168 ->getEventDispatcher()
168 ->dispatchScript('drupal-phpunit-upgrade'); 169 ->dispatchScript('drupal-phpunit-upgrade');
180 * 181 *
181 * @return bool 182 * @return bool
182 * TRUE if the PHPUnit needs to be upgraded, FALSE if not. 183 * TRUE if the PHPUnit needs to be upgraded, FALSE if not.
183 */ 184 */
184 public static function upgradePHPUnitCheck($phpunit_version) { 185 public static function upgradePHPUnitCheck($phpunit_version) {
185 return !(version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.2') >= 0 && version_compare($phpunit_version, '6.1') < 0); 186 return !(version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.0') >= 0 && version_compare($phpunit_version, '6.1') < 0);
186 } 187 }
187 188
188 /** 189 /**
189 * Remove possibly problematic test files from vendored projects. 190 * Remove possibly problematic test files from vendored projects.
190 * 191 *
268 } 269 }
269 return $package_key; 270 return $package_key;
270 } 271 }
271 272
272 /** 273 /**
274 * Removes Composer's timeout so that scripts can run indefinitely.
275 */
276 public static function removeTimeout() {
277 ProcessExecutor::setTimeout(0);
278 }
279
280 /**
273 * Helper method to remove directories and the files they contain. 281 * Helper method to remove directories and the files they contain.
274 * 282 *
275 * @param string $path 283 * @param string $path
276 * The directory or file to remove. It must exist. 284 * The directory or file to remove. It must exist.
277 * 285 *