mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-23 23:29:17 -05:00
fix: throw an error if nodeVersion is not a semver version (#9936)
ref #9934
This commit is contained in:
6
.changeset/major-cobras-clap.md
Normal file
6
.changeset/major-cobras-clap.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/package-is-installable": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Throw an error if `nodeVersion` is not set to an exact semver version [#9934](https://github.com/pnpm/pnpm/issues/9934).
|
||||
@@ -22,6 +22,9 @@ export function checkEngine (
|
||||
if (!wantedEngine) return null
|
||||
const unsatisfiedWanted: WantedEngine = {}
|
||||
if (wantedEngine.node && !semver.satisfies(currentEngine.node, wantedEngine.node, { includePrerelease: true })) {
|
||||
if (!semver.valid(currentEngine.node)) {
|
||||
throw new PnpmError('INVALID_NODE_VERSION', `The nodeVersion setting is "${currentEngine.node}", which is not exact semver version`)
|
||||
}
|
||||
unsatisfiedWanted.node = wantedEngine.node
|
||||
}
|
||||
if (currentEngine.pnpm && wantedEngine.pnpm && !semver.satisfies(currentEngine.pnpm, wantedEngine.pnpm, { includePrerelease: true })) {
|
||||
|
||||
@@ -16,6 +16,10 @@ test('node version too old', () => {
|
||||
expect(err?.wanted.node).toBe('0.10.24')
|
||||
})
|
||||
|
||||
test('node range passed in instead of version', () => {
|
||||
expect(() => checkEngine(packageId, { node: '21.0.0' }, { node: '>=20.0.0' })).toThrow('The nodeVersion setting is')
|
||||
})
|
||||
|
||||
test('pnpm version too old', () => {
|
||||
const err = checkEngine(packageId, { pnpm: '^1.4.6' }, { pnpm: '1.3.2', node: '0.2.1' })
|
||||
expect(err).toBeTruthy()
|
||||
|
||||
Reference in New Issue
Block a user