From e5fbac331ed4b6e2a7f7584205aeb116ef726c5e Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Fri, 9 Feb 2024 00:10:52 +0100 Subject: [PATCH] fix: don't print unnecessary warning in project that uses hoisted node_modules --- .changeset/smart-forks-march.md | 6 ++++++ pkg-manager/core/src/install/index.ts | 13 ++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 .changeset/smart-forks-march.md diff --git a/.changeset/smart-forks-march.md b/.changeset/smart-forks-march.md new file mode 100644 index 0000000000..9330803a5e --- /dev/null +++ b/.changeset/smart-forks-march.md @@ -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. diff --git a/pkg-manager/core/src/install/index.ts b/pkg-manager/core/src/install/index.ts index e1f22718e4..0ef9986612 100644 --- a/pkg-manager/core/src/install/index.ts +++ b/pkg-manager/core/src/install/index.ts @@ -898,13 +898,6 @@ type InstallFunction = ( ) => Promise 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 (