Merge pull request #8412 from polarathene/fix/improve-createproject-ux
Fix: Improve the create-project UXpull/8475/head
commit
92cc5a821f
|
@ -279,6 +279,24 @@ EOT
|
||||||
$packageVersion = $requirements[0]['version'];
|
$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 (null === $stability) {
|
||||||
if (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
|
if (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
|
||||||
$stability = $match[1];
|
$stability = $match[1];
|
||||||
|
@ -320,11 +338,6 @@ EOT
|
||||||
throw new \InvalidArgumentException($errorMessage .'.');
|
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
|
// handler Ctrl+C for unix-like systems
|
||||||
if (function_exists('pcntl_async_signals')) {
|
if (function_exists('pcntl_async_signals')) {
|
||||||
@mkdir($directory, 0777, true);
|
@mkdir($directory, 0777, true);
|
||||||
|
|
Loading…
Reference in New Issue