You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When checking pre-release ranges, the results are very confusing. I have read the documentation many times, run a bunch of tests and reviewed all bug tickets. There are several open and closed issues that seem related to this, but I still can't figure out how this is expected to work. For example:
npx semver --range ">=1.0.2-0" "1.0.3-6"
Results in a non-match. Why if the range is ">=" and the range explicitly includes prereleases via "-0"? This seems to be incorrect.
npx semver --range "^1.0.2-0" "1.0.3-6"
Also results in a non-match. This seems to also be incorrect.
npx semver --range "^1.0.2-0" "1.0.3"
Results in a match. This is correct, but doesn't make sense that this would match when "1.0.3-6" does not.
So then I looked at using --include-prerelease. This seemed like the right approach based on the "Prerelease Tags" section in the README. However, this causes behavior to seem incorrect in the other extreme:
Results in a match. Wait, what? This seems to completely contradict motivation expressed in the "Prerelease Tags" section.
So how can this be used effectively in automation to match versions in situations where we do want to include pre-releases from those where we do not if we cannot express that purely from the range expression itself? It seems to me that, the way this is designed, the range expression is barely (if at all) being used to decide if pre-releases are included.
The text was updated successfully, but these errors were encountered:
If I'm explicitly asking to include prereleases, then why would "1.0.2-6" not match while "1.0.3-6" does match? That behavior is baffling to me. That doesn't seem to consistently follow the README which states:
Note that this behavior can be suppressed (treating all prerelease versions as if they were normal versions, for range-matching) by setting the includePrerelease flag on the options object to any functions that do range matching.
I'm not sure if this is following some set of rules I just don't understand, or if range matching is buggy.
robross0606
changed the title
[QUESTION] Very confusing behavior for range matching
[QUESTION] Very confusing behavior for pre-release range matching
Jun 24, 2024
When checking pre-release ranges, the results are very confusing. I have read the documentation many times, run a bunch of tests and reviewed all bug tickets. There are several open and closed issues that seem related to this, but I still can't figure out how this is expected to work. For example:
Results in a non-match. Why if the range is ">=" and the range explicitly includes prereleases via "-0"? This seems to be incorrect.
Also results in a non-match. This seems to also be incorrect.
Results in a match. This is correct, but doesn't make sense that this would match when "1.0.3-6" does not.
Results in a match. This is correct.
So then I looked at using
--include-prerelease
. This seemed like the right approach based on the "Prerelease Tags" section in the README. However, this causes behavior to seem incorrect in the other extreme:Results in a match. Wait, what? This seems to completely contradict motivation expressed in the "Prerelease Tags" section.
So how can this be used effectively in automation to match versions in situations where we do want to include pre-releases from those where we do not if we cannot express that purely from the range expression itself? It seems to me that, the way this is designed, the range expression is barely (if at all) being used to decide if pre-releases are included.
The text was updated successfully, but these errors were encountered: