Fix: Fail fast when the project directory is not empty
Avoid waiting until after `getBestCandidate()` has finished, as it can add notably delay on slow connections due to downloading megabytes of data. Only to fail if the install location is invalid.pull/8412/head
parent
4e4c38795a
commit
e5e8736383
|
@ -279,6 +279,11 @@ EOT
|
||||||
$packageVersion = $requirements[0]['version'];
|
$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 (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];
|
||||||
|
|
Loading…
Reference in New Issue