Skip to content

Weird version range behavior when using includePrerelease: true #282

@mxlle

Description

@mxlle

I want to define a version range that matches all versions of a certain major, including any prereleases of this major.

I tried using just "2" or "2.x.x" and adding the includePrerelease: true option to all function calls, however then I get weird behavior at the corner cases:

semver.satisfies("2.0.0-pre.0", "2.x.x", {includePrerelease: true}); // false, I expected true
semver.satisfies("2.1.0-pre.0", "2.x.x", {includePrerelease: true}); // true
semver.satisfies("3.0.0-pre.0", "2.x.x", {includePrerelease: true}); // true, I expected false

I know that this behavior matches the definition of ^1.x := >=1.0.0 <2.0.0
However I think the behavior should be altered in case of the includePrerelease flag.

It's relevant for the following situation:

  • I implement a program against the interface of version 2.x.x.
  • I want to always get the newest version of this interface, also prereleases, so I use the includePrerelease flag.
  • However as soon as there is an 3.0.0-pre, this will break my interface because it's treated as 2.x.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions