mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-10 18:18:56 -04:00
fix: don't print a warning when --lockfile-only is used (#10044)
close #8320
This commit is contained in:
6
.changeset/fair-maps-hang.md
Normal file
6
.changeset/fair-maps-hang.md
Normal file
@@ -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).
|
||||
@@ -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 (
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user