Browse Source

Ensure missing packages are reinstalled if they are deleted from the filesystem, fixes #355, fixes #437

Jordi Boggiano 13 years ago
parent
commit
96b07ffb7b
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/Composer/Factory.php

+ 7 - 0
src/Composer/Factory.php

@@ -104,6 +104,13 @@ class Factory
         // initialize installation manager
         $im = $this->createInstallationManager($rm, $dm, $vendorDir, $binDir, $io);
 
+        // purge packages if they have been deleted on the filesystem
+        foreach ($rm->getLocalRepository()->getPackages() as $package) {
+            if (!$im->isPackageInstalled($package)) {
+                $rm->getLocalRepository()->removePackage($package);
+            }
+        }
+
         // init locker
         $lockFile = substr($composerFile, -5) === '.json' ? substr($composerFile, 0, -4).'lock' : $composerFile . '.lock';
         $locker = new Package\Locker(new JsonFile($lockFile), $rm, md5_file($composerFile));