Skip to content

Commit

Permalink
Fix support for lock:false in Composer
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek authored Oct 2, 2024
1 parent ed16f52 commit 6609d0a
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 6609d0a

Please sign in to comment.