Skip to content

Commit

Permalink
Merge pull request #268 from Seldaek/patch-1
Browse files Browse the repository at this point in the history
Fix support for lock:false in Composer
  • Loading branch information
dbu authored Oct 2, 2024
2 parents e0a99b0 + 6609d0a commit 59dd865
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Composer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,21 @@ private function updateComposerJson(array $missingRequires, bool $sortPackages)

private function updateComposerLock(Composer $composer, IOInterface $io)
{
if ($composer->getConfig()->get('lock') === false) {
return;
}

$lock = substr(Factory::getComposerFile(), 0, -4).'lock';
$composerJson = file_get_contents(Factory::getComposerFile());
$lockFile = new JsonFile($lock, null, $io);
$locker = ClassDiscovery::safeClassExists(RepositorySet::class)
? new Locker($io, $lockFile, $composer->getInstallationManager(), $composerJson)
: new Locker($io, $lockFile, $composer->getRepositoryManager(), $composer->getInstallationManager(), $composerJson);

if (!$locker->isLocked()) {
return;
}

$lockData = $locker->getLockData();
$lockData['content-hash'] = Locker::getContentHash($composerJson);
$lockFile->write($lockData);
Expand Down

0 comments on commit 59dd865

Please sign in to comment.