Skip to content

Commit

Permalink
fix: special version node check (#6509)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
  • Loading branch information
btea and zkochan committed May 7, 2023
1 parent 1ffa3ee commit f9be601
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
@@ -0,0 +1,6 @@
---
"@pnpm/package-is-installable": patch
"pnpm": patch
---

Node.js range specified through the `engines` field should match prerelease versions [#6509](https://github.com/pnpm/pnpm/pull/6509).
4 changes: 2 additions & 2 deletions config/package-is-installable/src/checkEngine.ts
Expand Up @@ -21,10 +21,10 @@ export function checkEngine (
) {
if (!wantedEngine) return null
const unsatisfiedWanted: WantedEngine = {}
if (wantedEngine.node && !semver.satisfies(currentEngine.node, wantedEngine.node)) {
if (wantedEngine.node && !semver.satisfies(currentEngine.node, wantedEngine.node, { includePrerelease: true })) {
unsatisfiedWanted.node = wantedEngine.node
}
if (currentEngine.pnpm && wantedEngine.pnpm && !semver.satisfies(currentEngine.pnpm, wantedEngine.pnpm)) {
if (currentEngine.pnpm && wantedEngine.pnpm && !semver.satisfies(currentEngine.pnpm, wantedEngine.pnpm, { includePrerelease: true })) {
unsatisfiedWanted.pnpm = wantedEngine.pnpm
}
if (Object.keys(unsatisfiedWanted).length > 0) {
Expand Down
4 changes: 4 additions & 0 deletions config/package-is-installable/test/checkEngine.ts
Expand Up @@ -6,6 +6,10 @@ test('no engine defined', () => {
expect(checkEngine(packageId, {}, { pnpm: '1.1.2', node: '0.2.1' })).toBe(null)
})

test('prerelease node version', () => {
expect(checkEngine(packageId, { node: '^14.18.0 || >=16.0.0' }, { node: 'v21.0.0-nightly20230429c968361829' })).toBe(null)
})

test('node version too old', () => {
const err = checkEngine(packageId, { node: '0.10.24' }, { pnpm: '1.1.2', node: '0.10.18' })
expect(err).toBeTruthy()
Expand Down
Expand Up @@ -18,4 +18,4 @@ test('getSystemNodeVersion() from a non-executable pnpm CLI', () => {
// @ts-expect-error
delete process['pkg']
expect(getSystemNodeVersionNonCached()).toBe(process.version)
})
})

0 comments on commit f9be601

Please sign in to comment.