[BUG] Why does not satisfy 1.7.0-rc.0 with range ^1?
Closed this issue · 11 comments
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
Why?
- https://jubianchi.github.io/semver-check/#/^1/1.7.0-rc.2 satisfies true
- semver.satisfies('1.7.0-rc.2', '^1') => false?!
Expected Behavior
semver.satisfies('1.7.0-rc.2', '^1') => true
Steps To Reproduce
- https://jubianchi.github.io/semver-check/#/^1/1.7.0-rc.2 satisfies true
- semver.satisfies('1.7.0-rc.2', '^1') => false?!
Environment
- pnpm: ^8
- Node: ^20
- OS: Mac
- platform: Intel
semver.satisfies(this.version, task.getVersionRange(), {
includePrerelease: true,
})
The problem is that includePrerelease
disregards/overrides the range specification. Per spec, the range itself should be able to specify whether or not it will accept pre-releases (e.g. "^1.0.2" vs "^1.0.2-0"). If you set includePrereleases=true
, then a version of "1.0.3-5" satisfies "^1.0.2" when it should not. Conversely, if you do not set includePrereleases
then "1.0.3-5" does not satisfy "^1.0.2-0" when it should.
^1.0.2-0 only allows prereleases for 1.0.2, so it shouldn’t accept a 1.0.3 prerelease (i assume you meant 1.0.3-5, since 1.0.3.5 isn’t valid semver)
^1.0.2-0 only allows prereleases for 1.0.2, so it shouldn’t accept a 1.0.3 prerelease (i assume you meant 1.0.3-5, since 1.0.3.5 isn’t valid semver)
@ljharb that's now how the semver spec is written ASAICT for "^". That is also not true here: https://jubianchi.github.io/semver-check/#/^1.0.2-0/1.0.3-5
The semver spec doesn't have ranges whatsoever, so I'm not sure what you're referring to.
https://semver.npmjs.com is the playground for how semver works in npm; i'm not familiar with "semver-check".
^1.0.2-0 only allows prereleases for 1.0.2, so it shouldn’t accept a 1.0.3 prerelease (i assume you meant 1.0.3-5, since 1.0.3.5 isn’t valid semver)
What range expression would accept a 1.0.3 prerelease?
^1.0.3-0
.
@ljharb, I can't tell if you're trolling or truly not understand the fundamental question, so I'll try to clarify. Similar to how "^1.0.0" or ">=1.0.0" would get you "1.0.3", what range expression using 1.0.2-0 as a baseline would get you 1.0.3-5?
@robross0606 i'm not trolling. the answer is none. there is, quite intentionally, no way to use a range and get prereleases for anything other than the specific full version indicated.
I had a feeling you would say "none" but I needed to hear it.
For example ~1.7.0-rc.0
updates to ~1.7.0-rc.1
, ~1.7.0-rc.2
and so on.
Thx for your work.