summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2016-03-30 10:41:48 (GMT)
committerNathaniel Catchpole2016-03-30 10:41:48 (GMT)
commite9fc0f1a97466d8926403ab1fc80efc1e09f8605 (patch)
tree85d4c0719836507e55d7cdddcf12b506a0fb1f44
parent920edd9d6e441c0f06685086be76acb9cc833250 (diff)
Issue #2664274 by alexpott, bojanz, fortis, Mile23, arknoll, Barryvdh: Combination of --prefer-dist and .gitattributes confuses our vendor test cleanup
-rw-r--r--core/lib/Drupal/Core/Composer/Composer.php30
1 files changed, 28 insertions, 2 deletions
diff --git a/core/lib/Drupal/Core/Composer/Composer.php b/core/lib/Drupal/Core/Composer/Composer.php
index cfc9155..2f1310f 100644
--- a/core/lib/Drupal/Core/Composer/Composer.php
+++ b/core/lib/Drupal/Core/Composer/Composer.php
@@ -149,6 +149,7 @@ EOT;
*/
public static function vendorTestCodeCleanup(PackageEvent $event) {
$vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir');
+ $io = $event->getIO();
$op = $event->getOperation();
if ($op->getJobType() == 'update') {
$package = $op->getTargetPackage();
@@ -157,14 +158,39 @@ EOT;
$package = $op->getPackage();
}
$package_key = static::findPackageKey($package->getName());
+ $message = sprintf(" Processing <comment>%s</comment>", $package->getPrettyName());
+ if ($io->isVeryVerbose()) {
+ $io->write($message);
+ }
if ($package_key) {
foreach (static::$packageToCleanup[$package_key] as $path) {
$dir_to_remove = $vendor_dir . '/' . $package_key . '/' . $path;
+ $print_message = $io->isVeryVerbose();
if (is_dir($dir_to_remove)) {
- if (!static::deleteRecursive($dir_to_remove)) {
- throw new \RuntimeException(sprintf("Failure removing directory '%s' in package '%s'.", $path, $package->getPrettyName()));
+ if (static::deleteRecursive($dir_to_remove)) {
+ $message = sprintf(" <info>Removing directory '%s'</info>", $path);
+ }
+ else {
+ // Always display a message if this fails as it means something has
+ // gone wrong. Therefore the message has to include the package name
+ // as the first informational message might not exist.
+ $print_message = TRUE;
+ $message = sprintf(" <error>Failure removing directory '%s'</error> in package <comment>%s</comment>.", $path, $package->getPrettyName());
}
}
+ else {
+ // If the package has changed or the --prefer-dist version does not
+ // include the directory this is not an error.
+ $message = sprintf(" Directory '%s' does not exist", $path);
+ }
+ if ($print_message) {
+ $io->write($message);
+ }
+ }
+
+ if ($io->isVeryVerbose()) {
+ // Add a new line to separate this output from the next package.
+ $io->write("");
}
}
}