Skip to content

Option to include prereleases when matching npm/cargo ranges #50

Description

@andrew

Range.Contains gates npm/cargo prereleases through semverIntervalAllowsPrerelease (range.go:64), which only admits a prerelease when a bound in the same interval carries a prerelease tag on the same major.minor.patch. That matches node-semver's default and is right for dependency resolution, but advisory matching needs prereleases inside the numeric range to match regardless of the bounds:

r, _ := vers.ParseNative("< 3.0.0", "npm")
r.Contains("1.7.0-alpha.2") // false; advisory matching wants true

node-semver exposes this as includePrerelease: true. One shape here would be a variadic option on Contains and Satisfies:

r.Contains("1.7.0-alpha.2", vers.IncludePrerelease())
vers.Satisfies("1.7.0-alpha.2", "< 3.0.0", "npm", vers.IncludePrerelease())

or a parallel method if changing the existing signatures is unwanted.

Same gap as andrew/vers#38 (Ruby side, fixed in andrew/vers#41).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions