diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 2985aa57a..e84234467 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -279,6 +279,11 @@ EOT $packageVersion = $requirements[0]['version']; } + $fs = new Filesystem(); + if (is_dir($directory) && !$fs->isDirEmpty($directory)) { + throw new \InvalidArgumentException("Project directory $directory is not empty."); + } + if (null === $stability) { if (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) { $stability = $match[1];