Skip to content

Commit

Permalink
Support relative paths in the generated config (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Dec 13, 2020
1 parent a22ec91 commit 66c7adc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Composer\Plugin\PluginInterface;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
use Composer\Util\Filesystem;
use function array_keys;
use function file_exists;
use function file_put_contents;
Expand Down Expand Up @@ -94,6 +95,7 @@ public function process(Event $event): void
$installedPackages = [];

$data = [];
$fs = new Filesystem();
foreach ($composer->getRepositoryManager()->getLocalRepository()->getPackages() as $package) {
if (
$package->getType() !== 'phpstan-extension'
Expand All @@ -112,8 +114,10 @@ public function process(Event $event): void
}
continue;
}
$absoluteInstallPath = $installationManager->getInstallPath($package);
$data[$package->getName()] = [
'install_path' => $installationManager->getInstallPath($package),
'install_path' => $absoluteInstallPath,
'relative_install_path' => $fs->findShortestPath(dirname($generatedConfigFilePath), $absoluteInstallPath, true),
'extra' => $package->getExtra()['phpstan'] ?? null,
'version' => $package->getFullPrettyVersion(),
];
Expand Down

0 comments on commit 66c7adc

Please sign in to comment.