parent
203f972ed7
commit
63da7c6b2d
|
@ -618,7 +618,7 @@ class Installer
|
|||
}
|
||||
|
||||
if ($this->executeOperations || $this->writeLock) {
|
||||
$localRepo->write($this->devMode);
|
||||
$localRepo->write($this->devMode, $this->installationManager);
|
||||
}
|
||||
|
||||
$event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($jobType);
|
||||
|
@ -630,7 +630,7 @@ class Installer
|
|||
if ($this->executeOperations) {
|
||||
// force source/dist urls to be updated for all packages
|
||||
$this->processPackageUrls($pool, $policy, $localRepo, $repositories);
|
||||
$localRepo->write($this->devMode);
|
||||
$localRepo->write($this->devMode, $this->installationManager);
|
||||
}
|
||||
|
||||
return array(0, $devPackages);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
namespace Composer\Repository;
|
||||
|
||||
use Composer\Package\AliasPackage;
|
||||
use Composer\Installer\InstallationManager;
|
||||
|
||||
/**
|
||||
* Writable array repository.
|
||||
|
@ -24,7 +25,7 @@ class WritableArrayRepository extends ArrayRepository implements WritableReposit
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function write($devMode)
|
||||
public function write($devMode, InstallationManager $installationManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
namespace Composer\Repository;
|
||||
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Installer\InstallationManager;
|
||||
|
||||
/**
|
||||
* Writable repository interface.
|
||||
|
@ -26,7 +27,7 @@ interface WritableRepositoryInterface extends RepositoryInterface
|
|||
*
|
||||
* @param bool $devMode Whether dev requirements were included or not in this installation
|
||||
*/
|
||||
public function write($devMode);
|
||||
public function write($devMode, InstallationManager $installationManager);
|
||||
|
||||
/**
|
||||
* Adds package to the repository.
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
namespace Composer\Test\Mock;
|
||||
|
||||
use Composer\Repository\InstalledFilesystemRepository;
|
||||
use Composer\Installer\InstallationManager;
|
||||
|
||||
class InstalledFilesystemRepositoryMock extends InstalledFilesystemRepository
|
||||
{
|
||||
|
@ -20,7 +21,7 @@ class InstalledFilesystemRepositoryMock extends InstalledFilesystemRepository
|
|||
{
|
||||
}
|
||||
|
||||
public function write($devMode)
|
||||
public function write($devMode, InstallationManager $installationManager)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class LockerTest extends TestCase
|
|||
$locker = new Locker(
|
||||
new NullIO,
|
||||
$json,
|
||||
$this->createRepositoryManagerMock(),
|
||||
$this->createInstallationManagerMock(),
|
||||
$this->getJsonContent()
|
||||
);
|
||||
|
||||
|
|
|
@ -82,11 +82,21 @@ class FilesystemRepositoryTest extends TestCase
|
|||
$json = $this->createJsonFileMock();
|
||||
|
||||
$repository = new FilesystemRepository($json);
|
||||
$im = $this->getMockBuilder('Composer\Installer\InstallationManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$im->expects($this->once())
|
||||
->method('getInstallPath')
|
||||
->will($this->returnValue('/foo/bar/vendor/woop/woop'));
|
||||
|
||||
$json
|
||||
->expects($this->once())
|
||||
->method('read')
|
||||
->will($this->returnValue(array()));
|
||||
$json
|
||||
->expects($this->once())
|
||||
->method('getPath')
|
||||
->will($this->returnValue('/foo/bar/vendor/composer/installed.json'));
|
||||
$json
|
||||
->expects($this->once())
|
||||
->method('exists')
|
||||
|
@ -95,12 +105,12 @@ class FilesystemRepositoryTest extends TestCase
|
|||
->expects($this->once())
|
||||
->method('write')
|
||||
->with(array(
|
||||
'packages' => array(array('name' => 'mypkg', 'type' => 'library', 'version' => '0.1.10', 'version_normalized' => '0.1.10.0')),
|
||||
'packages' => array(array('name' => 'mypkg', 'type' => 'library', 'version' => '0.1.10', 'version_normalized' => '0.1.10.0', 'install-path' => '../woop/woop')),
|
||||
'dev' => true,
|
||||
));
|
||||
|
||||
$repository->addPackage($this->getPackage('mypkg', '0.1.10'));
|
||||
$repository->write(true);
|
||||
$repository->write(true, $im);
|
||||
}
|
||||
|
||||
private function createJsonFileMock()
|
||||
|
|
Loading…
Reference in New Issue