diff --git a/.changeset/fair-maps-hang.md b/.changeset/fair-maps-hang.md new file mode 100644 index 0000000000..166a517aa3 --- /dev/null +++ b/.changeset/fair-maps-hang.md @@ -0,0 +1,6 @@ +--- +"@pnpm/core": patch +"pnpm": patch +--- + +Don't print a warning, when `--lockfile-only` is used [#8320](https://github.com/pnpm/pnpm/issues/8320). diff --git a/pkg-manager/core/src/install/index.ts b/pkg-manager/core/src/install/index.ts index d19cdab238..7c721d872d 100644 --- a/pkg-manager/core/src/install/index.ts +++ b/pkg-manager/core/src/install/index.ts @@ -1629,12 +1629,6 @@ const installInContext: InstallFunction = async (projects, ctx, opts) => { ignoredBuilds, } } - 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 ( diff --git a/pkg-manager/core/test/install/lockfileOnly.ts b/pkg-manager/core/test/install/lockfileOnly.ts index c976d2c651..47cd8c70e6 100644 --- a/pkg-manager/core/test/install/lockfileOnly.ts +++ b/pkg-manager/core/test/install/lockfileOnly.ts @@ -8,7 +8,6 @@ import { addDependenciesToPackage, install, } from '@pnpm/core' -import sinon from 'sinon' import { testDefaults } from '../utils/index.js' test('install with lockfileOnly = true', async () => { @@ -46,35 +45,6 @@ test('install with lockfileOnly = true', async () => { expect(project.readCurrentLockfile()).toBeFalsy() }) -test('warn when installing with lockfileOnly = true and node_modules exists', async () => { - const project = prepareEmpty() - const reporter = sinon.spy() - - const { updatedManifest: manifest } = await addDependenciesToPackage({}, ['is-positive'], testDefaults()) - await addDependenciesToPackage(manifest, ['rimraf@2.5.1'], testDefaults({ - lockfileOnly: true, - reporter, - })) - - expect(reporter.calledWithMatch({ - level: 'warn', - message: '`node_modules` is present. Lockfile only installation will make it out-of-date', - name: 'pnpm', - })).toBeTruthy() - - project.storeHas('rimraf', '2.5.1') - project.hasNot('rimraf') - - expect(manifest.dependencies!.rimraf).toBeTruthy() - - const lockfile = project.readLockfile() - expect(lockfile.importers['.'].dependencies?.rimraf).toBeTruthy() - expect(lockfile.packages['rimraf@2.5.1']).toBeTruthy() - - const currentLockfile = project.readCurrentLockfile() - expect(currentLockfile.packages['rimraf@2.5.1']).toBeFalsy() -}) - test('do not update the lockfile when lockfileOnly and frozenLockfile are both used', async () => { prepareEmpty() await addDependenciesToPackage({}, ['is-positive@1.0.0'], testDefaults({