Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: special version node check #6509

Merged
merged 4 commits into from May 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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)
})
})