Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: compare two ranges #178

Closed
ljharb opened this issue Nov 18, 2016 · 5 comments
Closed

Feature request: compare two ranges #178

ljharb opened this issue Nov 18, 2016 · 5 comments

Comments

@ljharb
Copy link

ljharb commented Nov 18, 2016

I'm trying to compare an existing semver range in a package.json, with a peerDependency range in another package.json - in other words, I want to see if the two ranges are compatible (ie, if there exists a version that satisfies both).

I tried playing with Range but couldn't come up with anything.

A simple example would be, ^1.2.3 and <= 1.3.0 should return either a semver range that satisfies both, or the highest version number that satisfies both (either is sufficient).

Is this possible?

@platinumazure
Copy link

Seems like maxSatisfying(versions, range) would be really nice, if it allowed no versions and just generated the max possible range. But it could get unbounded pretty quickly on pathological input.

@shellscape
Copy link

came to the project today to request exactly this. we're presently using a litany of regular expressions (from some very old legacy code that I haven't gotten around to replacing) - https://github.com/gilt/gilt-swig-assets/blob/master/lib/swig-install/lib/merge-util.js#L73

@rtfpessoa
Copy link
Contributor

+1
I was also looking into this, tried combining a couple of methods but I always end with false cases.

@rtfpessoa
Copy link
Contributor

@ljharb @platinumazure @shellscape take a look in the PR I just made. It should be what you need.

@isaacs
Copy link
Contributor

isaacs commented Jul 24, 2017

Landed in v5.4

@isaacs isaacs closed this as completed Jul 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants