Skip to content

Commit 66c7adc

Browse files
committed
Support relative paths in the generated config (#17)
1 parent a22ec91 commit 66c7adc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Plugin.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Composer\Plugin\PluginInterface;
99
use Composer\Script\Event;
1010
use Composer\Script\ScriptEvents;
11+
use Composer\Util\Filesystem;
1112
use function array_keys;
1213
use function file_exists;
1314
use function file_put_contents;
@@ -94,6 +95,7 @@ public function process(Event $event): void
9495
$installedPackages = [];
9596

9697
$data = [];
98+
$fs = new Filesystem();
9799
foreach ($composer->getRepositoryManager()->getLocalRepository()->getPackages() as $package) {
98100
if (
99101
$package->getType() !== 'phpstan-extension'
@@ -112,8 +114,10 @@ public function process(Event $event): void
112114
}
113115
continue;
114116
}
117+
$absoluteInstallPath = $installationManager->getInstallPath($package);
115118
$data[$package->getName()] = [
116-
'install_path' => $installationManager->getInstallPath($package),
119+
'install_path' => $absoluteInstallPath,
120+
'relative_install_path' => $fs->findShortestPath(dirname($generatedConfigFilePath), $absoluteInstallPath, true),
117121
'extra' => $package->getExtra()['phpstan'] ?? null,
118122
'version' => $package->getFullPrettyVersion(),
119123
];

0 commit comments

Comments
 (0)