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

[BUG]semver.Range returns pre-release version even when includePrerelease is set to false #396

Open
alan-agius4 opened this issue Aug 17, 2021 · 2 comments
Labels
Bug thing that needs fixing

Comments

@alan-agius4
Copy link

alan-agius4 commented Aug 17, 2021

What / Why

new semver.Range returns prerelease semver version even when includePrerelease is set to false with version 7.3.5.

How

Current Behavior

const semver = require('semver');
new semver.Range('^12.0.0 || ^13.0.0-rc.0', { includePrerelease: false})


options: Object {}
loose: false
includePrerelease: false
raw: "^12.0.0 || ^13.0.0-rc.0"
range: ">=12.0.0 <13.0.0-0||>=13.0.0-rc.0 <14.0.0-0"

Expected Behavior

range doesn't include pre-releases when includePrerelease is set to false.

+ range: ">=12.0.0 <13.0.0-0"
- range: ">=12.0.0 <13.0.0-0||>=13.0.0-rc.0 <14.0.0-0"
@ljharb
Copy link

ljharb commented Aug 17, 2021

I wouldn’t expect that; the option is whether non prerelease ranges should include it. An explicit prerelease range I’d expect will always include it.

@darcyclarke darcyclarke added the Bug thing that needs fixing label Jul 28, 2022
@WalkerCodeRanger
Copy link

I had the same confusion when I was first looking at this package. I at first thought that it would make sense that new semver.Range(range, { includePrerelease: true}) included all prerelease; new semver.Range(range, { includePrerelease: false}) included no prerelease; and new semver.Range(range) included prerelease per the rules about prerelease matching.

It would be clearer if the parameter were named includeAllPrerelease. That is what I have done in my own package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing
Projects
None yet
Development

No branches or pull requests

4 participants