Преглед изворни кода

Move code to new method cleanBackups()

vlakoff пре 9 година
родитељ
комит
496d29a793
1 измењених фајлова са 14 додато и 8 уклоњено
  1. 14 8
      src/Composer/Command/SelfUpdateCommand.php

+ 14 - 8
src/Composer/Command/SelfUpdateCommand.php

@@ -192,14 +192,7 @@ TAGSPUBKEY
 
         // remove saved installations of composer
         if ($input->getOption('clean-backups')) {
-            $finder = $this->getOldInstallationFinder($rollbackDir);
-
-            $fs = new Filesystem;
-            foreach ($finder as $file) {
-                $file = (string) $file;
-                $io->writeError('<info>Removing: '.$file.'</info>');
-                $fs->remove($file);
-            }
+            $this->cleanBackups($rollbackDir);
         }
 
         if ($err = $this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
@@ -322,6 +315,19 @@ TAGSPUBKEY
         }
     }
 
+    protected function cleanBackups($rollbackDir)
+    {
+        $finder = $this->getOldInstallationFinder($rollbackDir);
+        $io = $this->getIO();
+        $fs = new Filesystem;
+
+        foreach ($finder as $file) {
+            $file = (string) $file;
+            $io->writeError('<info>Removing: '.$file.'</info>');
+            $fs->remove($file);
+        }
+    }
+
     protected function getLastBackupVersion($rollbackDir)
     {
         $finder = $this->getOldInstallationFinder($rollbackDir);