fix(core): don't write a lockfile when useLockfile is false

ref #4073
This commit is contained in:
Zoltan Kochan
2022-01-04 04:13:26 +02:00
parent edb220f013
commit 7bac7e8be2
3 changed files with 24 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/core": patch
---
Don't write a lockfile if useLockfile is set to false.

View File

@@ -912,7 +912,9 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
])
} else {
await finishLockfileUpdates()
await writeWantedLockfile(ctx.lockfileDir, newLockfile, lockfileOpts)
if (opts.useLockfile) {
await writeWantedLockfile(ctx.lockfileDir, newLockfile, lockfileOpts)
}
if (opts.nodeLinker !== 'hoisted') {
// This is only needed because otherwise the reporter will hang

View File

@@ -24,6 +24,22 @@ test('installing with hoisted node-linker', async () => {
expect(fs.existsSync('node_modules/send/node_modules/ms')).toBeTruthy()
})
test('installing with hoisted node-linker and no lockfile', async () => {
prepareEmpty()
await install({
dependencies: {
ms: '1.0.0',
},
}, await testDefaults({
useLockfile: false,
nodeLinker: 'hoisted',
}))
expect(fs.realpathSync('node_modules/ms')).toEqual(path.resolve('node_modules/ms'))
expect(fs.existsSync('pnpm-lock.yaml')).toBeFalsy()
})
test('overwriting (is-positive@3.0.0 with is-positive@latest)', async () => {
const project = prepareEmpty()
const manifest = await addDependenciesToPackage(