Skip to content

Commit

Permalink
fix: install --frozen-lockfile --lockfile-only should work (#6915)
Browse files Browse the repository at this point in the history
close #6913
  • Loading branch information
zkochan committed Aug 6, 2023
1 parent aaefb07 commit ecad8a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .changeset/perfect-forks-beg.md
Original file line number Diff line number Diff line change
@@ -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).
2 changes: 1 addition & 1 deletion pkg-manager/core/src/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export async function mutateModules (
!opts.dedupe &&
installsOnly &&
(
frozenLockfile && !opts.lockfileOnly ||
frozenLockfile ||
opts.ignorePackageManifest ||
!needsFullResolution &&
opts.preferFrozenLockfile &&
Expand Down
13 changes: 4 additions & 9 deletions pkg-manager/core/test/install/lockfileOnly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
})

0 comments on commit ecad8a7

Please sign in to comment.