1
0
Fork 0

Merge pull request #8412 from polarathene/fix/improve-createproject-ux

Fix: Improve the create-project UX
pull/8475/head
Jordi Boggiano 2019-12-07 20:36:04 +01:00 committed by GitHub
commit 92cc5a821f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 5 deletions

View File

@ -279,6 +279,24 @@ 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 = array_pop($parts);
}
$directory = getcwd() . DIRECTORY_SEPARATOR . $directory;
$io->writeError('<info>Creating a "' . $packageName . '" project at "' . $directory . '"</info>');
$fs = new Filesystem();
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) {
if (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
$stability = $match[1];
@ -320,11 +338,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);