fix: comparison of hoistPattern values (#10713)

This commit is contained in:
Zoltan Kochan
2026-02-27 23:51:58 +01:00
committed by GitHub
parent 97f049fb6a
commit 05158d2cde
3 changed files with 10 additions and 4 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/headless": patch
"@pnpm/core": patch
---
Fix the comparison of current and previous hoistPattern and publicHoistPattern values.

View File

@@ -63,7 +63,7 @@ export async function validateModules (
}
if (
opts.forcePublicHoistPattern &&
!equals(modules.publicHoistPattern, opts.publicHoistPattern || undefined)
!equals(modules.publicHoistPattern ?? [], opts.publicHoistPattern ?? [])
) {
if (opts.forceNewModules && (rootProject != null)) {
await purgeModulesDirsOfImporter(opts, rootProject)
@@ -80,7 +80,7 @@ export async function validateModules (
if (opts.forceHoistPattern && (rootProject != null)) {
try {
if (!equals(opts.currentHoistPattern, opts.hoistPattern || undefined)) {
if (!equals(opts.currentHoistPattern ?? [], opts.hoistPattern ?? [])) {
throw new PnpmError(
'HOIST_PATTERN_DIFF',
'This modules directory was created using a different hoist-pattern value.' +

View File

@@ -334,8 +334,8 @@ export async function headlessInstall (opts: HeadlessOptions): Promise<Installat
nodeVersion: opts.currentEngine.nodeVersion,
pnpmVersion: opts.currentEngine.pnpmVersion,
supportedArchitectures: opts.supportedArchitectures,
includeUnchangedDeps: (!equals(opts.currentHoistPattern, opts.hoistPattern ?? undefined)) ||
(!equals(opts.currentPublicHoistPattern, opts.publicHoistPattern ?? undefined)),
includeUnchangedDeps: (!equals(opts.currentHoistPattern ?? [], opts.hoistPattern ?? [])) ||
(!equals(opts.currentPublicHoistPattern ?? [], opts.publicHoistPattern ?? [])),
} as LockfileToDepGraphOptions
const {
directDependenciesByImporterId,