Repository navigation
fix: return 0.0.0 prerelease lower bounds from minVersion - #945
Closed
thelastbackspace wants to merge 1 commit into
Closed
thelastbackspace wants to merge 1 commit into
thelastbackspace wants to merge 1 commit into
Conversation
minVersion returned 0.0.0 as soon as it satisfied the range, before looking at the comparators, so a lower 0.0.0 prerelease bound (>=0.0.0-alpha) or 0.0.0-0 under includePrerelease was skipped. Fixes npm#934
|
Is this a duplicate of #936 ? |
Author
|
Yes, sorry, I missed #936. Closing this in favour of it. |
|
No worries, thanks for confirming. Feel free to comment on the other PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
minVersionchecked0.0.0first and returned it whenever it matched, so a lower 0.0.0 prerelease never got a chance:minVersion('>=0.0.0-alpha <1.0.0')returned0.0.0instead of0.0.0-alphaminVersion('*', { includePrerelease: true })returned0.0.0instead of0.0.0-0Fix
Check
0.0.0-0first, since nothing sorts below it. If0.0.0matches, I still run the comparator loop and only return its result when it is lower than0.0.0(a 0.0.0 prerelease bound); otherwise0.0.0is returned like before. The loop now skips theANYcomparator (*), which it never saw before because the0.0.0shortcut always returned first.Without
includePrerelease,*,<2,<0.0.1-betaetc. still return0.0.0. One behavior change to call out:>=0.0.0-0now returns0.0.0-0, which does satisfy it.Testing
Added cases to
test/ranges/min-version.jsfor>=/>0.0.0 prerelease bounds (also inside||ranges in either order),>=0.0.0-0, andincludePrereleasewith*,<2and prerelease bounds. They fail on main and pass with this change.Fixes #934