fix(subset): check any as superset#375
Conversation
Adds short-circuit check if superset is `*`.
|
@isaacs, when you get a chance could you take a look at this request? If there's any concerns, I'll do my best to address them ASAP. The request for arborist in the References section of this request has a dependency on this being merged. Both of these would also resolve npm/cli#636 (and possibly its referenced tickets as well), so this has potential to resolve a ton of issues for users. Thank you! |
isaacs
left a comment
There was a problem hiding this comment.
The suggested short-circuit path can only be applied when the includePrerelease flag is set. Otherwise, it returns an incorrect result if the first range includes a prerelease on any of its versions.
| // everything is a subset of * | ||
| ['1.2.3', '*', true], | ||
| ['^1.2.3', '*', true], | ||
| ['^1.2.3-pre.0', '*', true], |
There was a problem hiding this comment.
This is incorrect, though. ^1.2.3-pre.0 is not a subset of * unless includePrerelease is set, because there are versions that satisfy ^1.2.3-pre.0 and do not satisfy *.
> semver.satisfies('1.2.3-pre.0', '^1.2.3-pre.0')
true
> semver.satisfies('1.2.3-pre.0', '*')
false
|
Ah, ok, this is a bug though: I think we need special handling of |
|
Ahh! This was already a problem, turns out! That should return false in non-prerelease mode, because the first set includes Ok, so the solution looks like this I think: |
|
This is also a bug: Because (in non-prerelease mode) |
|
Woah! Thanks for your great feedback! I had no idea about the pre-release matching, but it makes sense 😊 I see you set up another PR, requesting my review, so I'll check that out now. Thanks! 👍 |
|
This is landed in #377. Thanks for bringing up the issue! Was a pretty significant oversight, which didn't matter until Arborist started making this method load-bearing 😬 |
Summary
Adds short-circuit check if superset is
*. This is currently not handled. A non-range semver has been able to get passed this not existing, but ranges came back falsey. This request addresses that shortcoming.References
Fixes #374.