diff --git a/doc/06-config.md b/doc/06-config.md index 636cf955508c..d89aa062d913 100644 --- a/doc/06-config.md +++ b/doc/06-config.md @@ -396,7 +396,7 @@ in the Composer home, cache, and data directories. ## lock Defaults to `true`. If set to `false`, Composer will not create a `composer.lock` -file. +file and will ignore it if one is present. ## platform-check diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index ee0b07f3e3bb..9288da19b914 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -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(''.$lockFile.' is present but ignored as the "lock" config option is disabled.'); + } - $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); } diff --git a/src/Composer/Util/Platform.php b/src/Composer/Util/Platform.php index 756c115063ac..163bf36d4aed 100644 --- a/src/Composer/Util/Platform.php +++ b/src/Composer/Util/Platform.php @@ -249,4 +249,13 @@ private static function isVirtualBoxGuest() return self::$isVirtualBoxGuest; } + + public static function getDevNull() + { + if (self::isWindows()) { + return 'NUL'; + } + + return '/dev/null'; + } }