瀏覽代碼

Fix: Check for null install directory earlier

Allows for failing fast when no install directory was provided to the command(uses package name instead).
polarathene 5 年之前
父節點
當前提交
11207a9a2e
共有 1 個文件被更改,包括 6 次插入5 次删除
  1. 6 5
      src/Composer/Command/CreateProjectCommand.php

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

@@ -279,6 +279,12 @@ EOT
             $packageVersion = $requirements[0]['version'];
         }
 
+        // if no directory was specified, use the 2nd part of the package name
+        if (null === $directory) {
+            $parts = explode("/", $name, 2);
+            $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
+        }
+
         $fs = new Filesystem();
         if (is_dir($directory) && !$fs->isDirEmpty($directory)) {
             throw new \InvalidArgumentException("Project directory $directory is not empty.");
@@ -325,11 +331,6 @@ EOT
             throw new \InvalidArgumentException($errorMessage .'.');
         }
 
-        if (null === $directory) {
-            $parts = explode("/", $name, 2);
-            $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
-        }
-
         // handler Ctrl+C for unix-like systems
         if (function_exists('pcntl_async_signals')) {
             @mkdir($directory, 0777, true);