Fix create-project regression when using path repos with relative paths, fixes #12150
parent
fa5b361f34
commit
e12cfa0c40
|
@ -424,21 +424,16 @@ EOT
|
|||
throw new \InvalidArgumentException($errorMessage .'.');
|
||||
}
|
||||
|
||||
$oldCwd = Platform::getCwd();
|
||||
// handler Ctrl+C aborts gracefully
|
||||
@mkdir($directory, 0777, true);
|
||||
if (false !== ($realDir = realpath($directory))) {
|
||||
$signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal, SignalHandler $handler) use ($realDir, $oldCwd) {
|
||||
chdir($oldCwd);
|
||||
$signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal, SignalHandler $handler) use ($realDir) {
|
||||
$this->getIO()->writeError('Received '.$signal.', aborting', true, IOInterface::DEBUG);
|
||||
$fs = new Filesystem();
|
||||
$fs->removeDirectory($realDir);
|
||||
$handler->exitWithLastSignal();
|
||||
});
|
||||
}
|
||||
if (!chdir($directory)) {
|
||||
throw new \RuntimeException('Failed to chdir into the new project dir at '.$directory);
|
||||
}
|
||||
|
||||
// avoid displaying 9999999-dev as version if default-branch was selected
|
||||
if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
|
||||
|
@ -472,6 +467,7 @@ EOT
|
|||
$installedFromVcs = 'source' === $package->getInstallationSource();
|
||||
|
||||
$io->writeError('<info>Created project in ' . $directory . '</info>');
|
||||
chdir($directory);
|
||||
|
||||
// ensure that the env var being set does not interfere with create-project
|
||||
// as it is probably not meant to be used here, so we do not use it if a composer.json can be found
|
||||
|
|
|
@ -350,7 +350,14 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
$this->io->writeError(" - " . InstallOperation::format($package));
|
||||
}
|
||||
|
||||
$vendorDir = $this->config->get('vendor-dir');
|
||||
|
||||
// clean up the target directory, unless it contains the vendor dir, as the vendor dir contains
|
||||
// the file to be installed. This is the case when installing with create-project in the current directory
|
||||
// but in that case we ensure the directory is empty already in ProjectInstaller so no need to empty it here.
|
||||
if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path.DIRECTORY_SEPARATOR))) {
|
||||
$this->filesystem->emptyDirectory($path);
|
||||
}
|
||||
$this->filesystem->ensureDirectoryExists($path);
|
||||
$this->filesystem->rename($this->getFileName($package, $path), $path . '/' . $this->getDistPath($package, PATHINFO_BASENAME));
|
||||
|
||||
|
|
Loading…
Reference in New Issue