fix: negate error on install without lockfile (#6851)

Change the error message to indicate the wanted lockfile is absent, not
present. This now reflects the actual error.

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
David Baynard
2023-07-30 01:00:52 +01:00
committed by GitHub
parent 347ca9f303
commit 5e7ee2473a
3 changed files with 8 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/core": patch
"pnpm": patch
---
Change the install error message when a lockfile is wanted but absent to indicate the wanted lockfile is absent, not present. This now reflects the actual error [#6851](https://github.com/pnpm/pnpm/pull/6851).

View File

@@ -416,7 +416,7 @@ Note that in CI environments, this setting is enabled by default.`,
if (!satisfies) {
if (!ctx.existsWantedLockfile) {
throw new PnpmError('NO_LOCKFILE',
`Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is present`, {
`Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is absent`, {
hint: 'Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"',
})
}

View File

@@ -124,7 +124,7 @@ test(`frozen-lockfile: should fail if no ${WANTED_LOCKFILE} is present`, async (
'is-positive': '^3.0.0',
},
}, await testDefaults({ frozenLockfile: true }))
).rejects.toThrow(`Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is present`)
).rejects.toThrow(`Cannot install with "frozen-lockfile" because ${WANTED_LOCKFILE} is absent`)
})
test(`prefer-frozen-lockfile: should prefer headless installation when ${WANTED_LOCKFILE} satisfies package.json`, async () => {