1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-11 09:32:55 +00:00

Add install-path to the installed.json for every package, fixes #2174, closes #2424

This commit is contained in:
Jordi Boggiano 2019-08-02 21:39:26 +02:00
parent 203f972ed7
commit 63da7c6b2d
No known key found for this signature in database
GPG key ID: 7BBD42C429EC80BC
7 changed files with 31 additions and 11 deletions

View file

@ -15,6 +15,8 @@ namespace Composer\Repository;
use Composer\Json\JsonFile;
use Composer\Package\Loader\ArrayLoader;
use Composer\Package\Dumper\ArrayDumper;
use Composer\Installer\InstallationManager;
use Composer\Util\Filesystem;
/**
* Filesystem repository.
@ -84,13 +86,18 @@ class FilesystemRepository extends WritableArrayRepository
/**
* Writes writable repository.
*/
public function write($devMode)
public function write($devMode, InstallationManager $installationManager)
{
$data = array('packages' => array(), 'dev' => $devMode);
$dumper = new ArrayDumper();
$fs = new Filesystem();
$repoDir = dirname($fs->normalizePath($this->file->getPath()));
foreach ($this->getCanonicalPackages() as $package) {
$data['packages'][] = $dumper->dump($package);
$pkgArray = $dumper->dump($package);
$path = $installationManager->getInstallPath($package);
$pkgArray['install-path'] = ('' !== $path && null !== $path) ? $fs->findShortestPath($repoDir, $path, true) : null;
$data['packages'][] = $pkgArray;
}
usort($data['packages'], function ($a, $b) {