Repository navigation
fix: return prerelease of 0.0.0 from minVersion when it is the minimum - #936
Open
thisisshivamtiwari wants to merge 1 commit into
Open
thisisshivamtiwari wants to merge 1 commit into
thisisshivamtiwari wants to merge 1 commit into
Conversation
minVersion tried 0.0.0 before 0.0.0-0 and returned it as soon as it matched, so a lower bound such as >=0.0.0-alpha, or any range with includePrerelease, gave 0.0.0 instead of the lower prerelease. Fixes npm#934
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.
Fixes #934
minVersionchecked0.0.0before0.0.0-0and returned it as soon as it matched. Since every prerelease of0.0.0sorts below0.0.0, that shortcut returned the wrong answer whenever a0.0.0prerelease also matches:Changes in
ranges/min-version.js:0.0.0-0first, since it is the lowest possible version.0.0.0matches, still run the normal lower-bound loop and return its result only when it matches and is below0.0.0. Otherwise return0.0.0as before. This keeps every existing result: when the loop finds nothing lower, the answer is still0.0.0.ANYcomparators in the loop. Before this change the loop never saw them, because any range containing*matched0.0.0and returned early.Without
includePrerelease,*and<2still return0.0.0, which matches the expectation in the issue thread.Tests
test/ranges/min-version.jsfor0.0.0prerelease lower bounds (>=,>, in a union, and an impossible prerelease set next to<1that must still fall back to0.0.0), plusincludePrereleasecases. The new cases fail onmainand pass with this change.JSON.stringifyso the newincludePrereleasecases have readable names.npm test(tap with 100% coverage, then eslint andtemplate-oss-check) passes locally.🤖 Generated with Claude Code