function Composer::vendorTestCodeCleanup
Same name in other branches
- 9 core/lib/Drupal/Core/Composer/Composer.php \Drupal\Core\Composer\Composer::vendorTestCodeCleanup()
Remove possibly problematic test files from vendored projects.
Parameters
\Composer\Installer\PackageEvent $event: A PackageEvent object to get the configured composer vendor directories from.
File
-
core/
lib/ Drupal/ Core/ Composer/ Composer.php, line 166
Class
- Composer
- Provides static functions for composer script events.
Namespace
Drupal\Core\ComposerCode
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();
}
else {
$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)) {
$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("");
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.