Also clean backups if no Composer update actually performed
parent
496d29a793
commit
93e08fd78e
|
@ -105,6 +105,11 @@ EOT
|
||||||
if (Composer::VERSION === $updateVersion) {
|
if (Composer::VERSION === $updateVersion) {
|
||||||
$io->writeError('<info>You are already using composer version '.$updateVersion.'.</info>');
|
$io->writeError('<info>You are already using composer version '.$updateVersion.'.</info>');
|
||||||
|
|
||||||
|
// remove all backups except for the most recent, if any
|
||||||
|
if ($input->getOption('clean-backups')) {
|
||||||
|
$this->cleanBackups($rollbackDir, $this->getLastBackupVersion());
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,13 +320,16 @@ TAGSPUBKEY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function cleanBackups($rollbackDir)
|
protected function cleanBackups($rollbackDir, $except = null)
|
||||||
{
|
{
|
||||||
$finder = $this->getOldInstallationFinder($rollbackDir);
|
$finder = $this->getOldInstallationFinder($rollbackDir);
|
||||||
$io = $this->getIO();
|
$io = $this->getIO();
|
||||||
$fs = new Filesystem;
|
$fs = new Filesystem;
|
||||||
|
|
||||||
foreach ($finder as $file) {
|
foreach ($finder as $file) {
|
||||||
|
if ($except && $file->getBasename(self::OLD_INSTALL_EXT) === $except) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$file = (string) $file;
|
$file = (string) $file;
|
||||||
$io->writeError('<info>Removing: '.$file.'</info>');
|
$io->writeError('<info>Removing: '.$file.'</info>');
|
||||||
$fs->remove($file);
|
$fs->remove($file);
|
||||||
|
|
Loading…
Reference in New Issue