Skip to content

Commit

Permalink
Fixed lock file being used when lock:false is in config, refs #10715
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Apr 13, 2022
1 parent 9bfd059 commit 0c7eacb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Composer/Factory.php
Expand Up @@ -442,8 +442,11 @@ public function createComposer(IOInterface $io, $localConfig = null, $disablePlu
// init locker if possible
if ($fullLoad && isset($composerFile)) {
$lockFile = self::getLockFile($composerFile);
if (!$config->get('lock') && file_exists($lockFile)) {
$io->writeError('<warning>'.$lockFile.' is present but ignored as the "lock" config option is disabled.</warning>');
}

$locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $im, file_get_contents($composerFile), $process);
$locker = new Package\Locker($io, new JsonFile($config->get('lock') ? $lockFile : Platform::getDevNull(), null, $io), $im, file_get_contents($composerFile), $process);
$composer->setLocker($locker);
}

Expand Down
9 changes: 9 additions & 0 deletions src/Composer/Util/Platform.php
Expand Up @@ -249,4 +249,13 @@ private static function isVirtualBoxGuest()

return self::$isVirtualBoxGuest;
}

public static function getDevNull()
{
if (self::isWindows()) {
return 'NUL';
}

return '/dev/null';
}
}

0 comments on commit 0c7eacb

Please sign in to comment.