fix: install --frozen-lockfile --lockfile-only should work (#6915)

close #6913
This commit is contained in:
Zoltan Kochan
2023-08-06 12:17:02 +03:00
committed by GitHub
parent aaefb07d0b
commit ecad8a724d
3 changed files with 11 additions and 10 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/core": patch
"pnpm": patch
---
`pnpm install --frozen-lockfile --lockfile-only` should fail if the lockfile is not up to date with the `package.json` files [#6913](https://github.com/pnpm/pnpm/issues/6913).

View File

@@ -373,7 +373,7 @@ export async function mutateModules (
!opts.dedupe &&
installsOnly &&
(
frozenLockfile && !opts.lockfileOnly ||
frozenLockfile ||
opts.ignorePackageManifest ||
!needsFullResolution &&
opts.preferFrozenLockfile &&

View File

@@ -75,22 +75,17 @@ test('warn when installing with lockfileOnly = true and node_modules exists', as
expect(currentLockfile.packages['/rimraf@2.5.1']).toBeFalsy()
})
// For @pnpm/core it might make sense to throw an exception in this case but for now it is better than having
// the https://github.com/pnpm/pnpm/issues/4951 issue.
test('always update the lockfile when lockfileOnly is used, even if frozenLockfile is used', async () => {
const project = prepareEmpty()
test('do not update the lockfile when lockfileOnly and frozenLockfile are both used', async () => {
prepareEmpty()
await addDependenciesToPackage({}, ['is-positive@1.0.0'], await testDefaults({
lockfileOnly: true,
}))
await install({
await expect(install({
dependencies: {
'is-positive': '2.0.0',
},
}, await testDefaults({
lockfileOnly: true,
frozenLockfile: true,
}))
const lockfile = await project.readLockfile()
expect(lockfile.dependencies['is-positive'].specifier).toBe('2.0.0')
}))).rejects.toThrow(/is not up to date/)
})