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.
main
polarathene 5 years ago committed by Brennan Kinney
parent 4e4c38795a
commit e5e8736383

@ -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];

Loading…
Cancel
Save