Explorar el Código

Fix: Fail when install location is a file

In the event a file has the same name as the intended install directory, fail fast too.
polarathene hace 5 años
padre
commit
5987114f6c
Se han modificado 1 ficheros con 6 adiciones y 2 borrados
  1. 6 2
      src/Composer/Command/CreateProjectCommand.php

+ 6 - 2
src/Composer/Command/CreateProjectCommand.php

@@ -286,8 +286,12 @@ EOT
         }
 
         $fs = new Filesystem();
-        if (is_dir($directory) && !$fs->isDirEmpty($directory)) {
-            throw new \InvalidArgumentException("Project directory $directory is not empty.");
+        if (file_exists($directory)) {
+            if (!is_dir($directory)) {
+                throw new \InvalidArgumentException('Cannot create project directory at "'.$directory.'", it exists as a file.');
+            } elseif (!$fs->isDirEmpty($directory)) {
+                throw new \InvalidArgumentException('Project directory "'.$directory.'" is not empty.');
+            }
         }
 
         if (null === $stability) {