fix: lockfile v6 repeat install when use-lockfile-v6 is not set

This commit is contained in:
Zoltan Kochan
2023-01-11 01:09:08 +02:00
parent 5a5512f14c
commit 9d425962f4
3 changed files with 11 additions and 3 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/core": patch
"pnpm": patch
---
Don't break lockfile v6 on repeat install if `use-lockfile-v6` is not set to `true`.

View File

@@ -120,7 +120,7 @@ export interface StrictInstallOptions {
allProjects: ProjectOptions[]
resolveSymlinksInInjectedDirs: boolean
dedupeDirectDeps: boolean
useLockfileV6: boolean
useLockfileV6?: boolean
}
export type InstallOptions =
@@ -207,7 +207,6 @@ const defaults = async (opts: InstallOptions) => {
resolveSymlinksInInjectedDirs: false,
dedupeDirectDeps: false,
resolvePeersFromWorkspaceRoot: false,
useLockfileV6: false,
} as StrictInstallOptions
}

View File

@@ -279,6 +279,9 @@ export async function mutateModules (
path: path.join(opts.lockfileDir, patchFile.path),
}), patchedDependencies)
: undefined
if (opts.useLockfileV6 == null) {
opts.useLockfileV6 = ctx.wantedLockfile.lockfileVersion.toString().startsWith('6.')
}
let needsFullResolution = !maybeOpts.ignorePackageManifest &&
lockfileIsUpToDate(ctx.wantedLockfile, {
overrides: opts.overrides,
@@ -879,7 +882,7 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
: newLockfile
if (opts.updateLockfileMinorVersion) {
if (opts.useLockfileV6 || newLockfile.lockfileVersion.toString().startsWith('6.')) {
if (opts.useLockfileV6) {
newLockfile.lockfileVersion = LOCKFILE_VERSION_V6
} else {
newLockfile.lockfileVersion = LOCKFILE_VERSION