From f06dbb052ddc394e7896fcd1cfcd533f9f6ace40 Mon Sep 17 00:00:00 2001 From: Brad <28307684+mad-briller@users.noreply.github.com> Date: Mon, 17 Oct 2022 13:53:58 +0100 Subject: [PATCH] Fixed issue where getInstallPath can return a relative path in rare cases. --- src/Plugin.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Plugin.php b/src/Plugin.php index 25b16aa..4ff82e4 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -13,6 +13,7 @@ use function dirname; use function file_exists; use function file_put_contents; +use function getcwd; use function in_array; use function is_file; use function ksort; @@ -21,6 +22,7 @@ use function sprintf; use function strpos; use function var_export; +use const DIRECTORY_SEPARATOR; final class Plugin implements PluginInterface, EventSubscriberInterface { @@ -116,7 +118,13 @@ public function process(Event $event): void } continue; } - $absoluteInstallPath = $installationManager->getInstallPath($package); + + $installPath = $installationManager->getInstallPath($package); + + $absoluteInstallPath = $fs->isAbsolutePath($installPath) + ? $installPath + : getcwd() . DIRECTORY_SEPARATOR . $installPath; + $data[$package->getName()] = [ 'install_path' => $absoluteInstallPath, 'relative_install_path' => $fs->findShortestPath(dirname($generatedConfigFilePath), $absoluteInstallPath, true),