fix: don't print unnecessary warning in project that uses hoisted node_modules

This commit is contained in:
Zoltan Kochan
2024-02-09 00:10:52 +01:00
parent f67ad31f64
commit e5fbac331e
2 changed files with 12 additions and 7 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/core": patch
"pnpm": patch
---
Don't print an unnecessary warning when adding new dependencies to a project that uses hoisted node_modules.

View File

@@ -898,13 +898,6 @@ type InstallFunction = (
) => Promise<InstallFunctionResult>
const _installInContext: InstallFunction = async (projects, ctx, opts) => {
if (opts.lockfileOnly && ctx.existsCurrentLockfile) {
logger.warn({
message: '`node_modules` is present. Lockfile only installation will make it out-of-date',
prefix: ctx.lockfileDir,
})
}
// The wanted lockfile is mutated during installation. To compare changes, a
// deep copy before installation is needed. This copy should represent the
// original wanted lockfile on disk as close as possible.
@@ -1396,6 +1389,12 @@ const installInContext: InstallFunction = async (projects, ctx, opts) => {
stats,
}
}
if (opts.lockfileOnly && ctx.existsCurrentLockfile) {
logger.warn({
message: '`node_modules` is present. Lockfile only installation will make it out-of-date',
prefix: ctx.lockfileDir,
})
}
return await _installInContext(projects, ctx, opts)
} catch (error: any) { // eslint-disable-line
if (