Comments (10)
Based on the comments/code it's the docs that are wrong. Didn't want to submit a request because I'm not certain which should be fixed.
from node-semver.
(https://github.com/isaacs/npm/issues/3036 is a direct duplicate of this)
The tests and the code seem to agree (https://github.com/isaacs/node-semver/blob/master/test.js#L386-L387), the docs don't.
from node-semver.
@nathan7 , @isaacs - Are you sure this is the intended behavior of "~1.2" ???
The following is taken from: https://npmjs.org/doc/json.html#dependencies
A range specifier starting with a tilde ~ character is matched against a version in the following fashion.
The version must be at least as high as the range.
The version must be less than the next major revision above the range.For example, the following are equivalent:
"~1.2.3" = ">=1.2.3 <1.3.0"
"~1.2" = ">=1.2.0 <2.0.0"
"~1" = ">=1.0.0 <2.0.0"
One would think that the version must be "less than the next major revision above the range." The "next major revision above the range" for "~1.2.3" is technically "2.0"... what's going on here?
In that case, shouldn't it be:
"~1.2.3" = ">=1.2.3 <2.0.0"
"~1.2" = ">=1.2.0 <2.0.0"
"~1" = ">=1.0.0 <2.0.0"
Or... what makes the most sense to me is what was originally documented. That is, "~1" should mean "something like version 1, which implies >=1.0.0 < 2.0.0". And, similarly, "~1.2" should mean "something like 1.2 which implies >=1.2.0 <1.3.0". Something like 1.2.3 should mean ">=1.2.3 <1.3".
from node-semver.
Yes, we discussed this and decided to make the docs comply, not the code. I'll fix up the npm docs too.
from node-semver.
@nathan7 - OK, cool. Thanks for clearing this up!
from node-semver.
I understand this is long closed - but why was this decided? It seems to me like the original docs were correct (they're what I expected). Right now Tilde behaves differently for different ranges:
~1.2.3 matches to the next minor change (one version up from what is specified)
~1.2 also matches to the next minor change (the same as the version specified).
Right now there is no single operator way to describe the [1.2 >= x < 2.0] while there are three for [1.2 >= x < 1.3]:
1.2.x
~1.2.0
~1.2
from node-semver.
^1.2
should match 1.2 >= x < 2.0
See https://semver.npmjs.com/
You can think of ~
(tilde) as "upgrade patch only"
You can think of ^
(caret) as "upgrade minor or patch only"
from node-semver.
You can think of ~ (tilde) as "upgrade patch only"
Unless you do ~1 of course. I expected to to mean "compatible with" - similar to caret without the special casing leading zeros (for me I think caret will work, as we're luckily past version 0). But looking at it more closely I can now see tilde is kind of a reverse ordered caret. I still think it's odd, and the original documented definition would have made more sense, but I can see that ship has sailed :) Thanks for taking the time to answer me, it's appreciated.
from node-semver.
@Linden-Ryuujin Huh, yeah, ~1
is effectively the same as 1.x.x
. That feels wrong to me. I'd expect it would be the same as ~1.0.0
.
Since ^
is more popular anyway, it'd probably do more harm than good to change the behavior of ~1
.
from node-semver.
(Also this issue is 5 years old. Let's let it rest in peace.)
from node-semver.
Related Issues (20)
- [QUESTION] Range class represents a range-set? HOT 1
- [BUG] Version without bugfix is considered invalid HOT 1
- [BUG] RC version without dash passes `validSemver` but fails on `semverCompare` HOT 4
- > ### Is there an existing issue for this?
- [BUG?] Remove redundant conditions from `Range` HOT 1
- [BUG] this.build missing from format() HOT 2
- [BUG] semver.valid does not reject multiple hyphens in pre-release section HOT 1
- [QUESTION] Inconsistent definition of version prefix HOT 3
- [BUG] limit version prefix to optional `v` HOT 4
- [BUG] Intersects returns `false` when it shouldn't HOT 2
- wild card entry specialtilde ( * ) bug HOT 1
- [BUG] `subset('>=17.2.0', '^17.2.0 || >17')` should be `true`
- [ENHANCEMENT] Publish package as standard JS modules HOT 13
- [ENHANCEMENT] Support for unicode symbols ≥ and ≤ HOT 4
- [QUESTION] Very confusing behavior for pre-release range matching HOT 2
- [BUG] package version upgrade could break instanceof HOT 11
- [BUG] wrong results on semver.npmjs.com HOT 5
- [ENHANCEMENT] Allow * prerelease versions for * version ranges. HOT 1
- [BUG] <title> HOT 1
- [ENHANCMENT] Add explicit "release" identifier to `inc` function to strip prerelease suffix from the version. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-semver.