Git Product home page Git Product logo

Comments (10)

scott2449 avatar scott2449 commented on August 25, 2024

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.

edef1c avatar edef1c commented on August 25, 2024

(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.

bminer avatar bminer commented on August 25, 2024

@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.

edef1c avatar edef1c commented on August 25, 2024

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.

bminer avatar bminer commented on August 25, 2024

@nathan7 - OK, cool. Thanks for clearing this up!

from node-semver.

Linden-Ryuujin avatar Linden-Ryuujin commented on August 25, 2024

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.

bminer avatar bminer commented on August 25, 2024

^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.

Linden-Ryuujin avatar Linden-Ryuujin commented on August 25, 2024

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.

isaacs avatar isaacs commented on August 25, 2024

@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.

isaacs avatar isaacs commented on August 25, 2024

(Also this issue is 5 years old. Let's let it rest in peace.)

from node-semver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.