Forráskód Böngészése

Allow create-project to be called in an empty dir that exists, fixes #1135, replaces #1206

Jordi Boggiano 12 éve
szülő
commit
2a23f8c48b
1 módosított fájl, 4 hozzáadás és 2 törlés
  1. 4 2
      src/Composer/Installer/ProjectInstaller.php

+ 4 - 2
src/Composer/Installer/ProjectInstaller.php

@@ -58,13 +58,15 @@ class ProjectInstaller implements InstallerInterface
     public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
     {
         $installPath = $this->installPath;
-        if (file_exists($installPath)) {
+        if (file_exists($installPath) && (count(glob($installPath.'/*')) || count(glob($installPath.'/.*')) > 2)) {
             throw new \InvalidArgumentException("Project directory $installPath already exists.");
         }
         if (!file_exists(dirname($installPath))) {
             throw new \InvalidArgumentException("Project root " . dirname($installPath) . " does not exist.");
         }
-        mkdir($installPath, 0777);
+        if (!is_dir($installPath)) {
+            mkdir($installPath, 0777);
+        }
         $this->downloadManager->download($package, $installPath);
     }