node-pty icon indicating copy to clipboard operation
node-pty copied to clipboard

Fix beta versioning

Open lydell opened this issue 1 year ago • 0 comments
trafficstars

Beta versions currently have suffixes like -beta1, -beta2, -beta3 etc. That works fine until we reach -beta10. Unfortunately, the 10 in there is not treated numerically, so according to npm’s semver -beta2 is “higher” than -beta10. Numbers only seem to be treated numerically when preceded by a ..

This is problematic because:

  • ^1.1.0-beta1 happens to work as expected.
  • ^1.1.0-beta2 on the other hand matches 1.1.0-beta2 to 1.1.0-beta9 and then 1.1.0-beta20, but not 1.1.0-beta10 to 1.1.0-beta19.

You can play around with the above at https://semver.npmjs.com/.

In this example, I want -1 all the time, but it fails when going from 9 to 10:

> require("semver").compare("1.0.0-beta8", "1.0.0-beta9")
-1

> require("semver").compare("1.0.0-beta9", "1.0.0-beta10")
1 // 🚨 !!!

> require("semver").compare("1.0.0-beta10", "1.0.0-beta11")
-1

But with a dot it works:

> require("semver").compare("1.0.0-beta.8", "1.0.0-beta.9")
-1

> require("semver").compare("1.0.0-beta.9", "1.0.0-beta.10")
-1

> require("semver").compare("1.0.0-beta.10", "1.0.0-beta.11")
-1

Unfortunately, 1.1.0-beta.13 is considered lower than 1.1.0-beta12, so I recommend waiting with merging this until you have released the next stable version.

> require("semver").compare("1.1.0-beta.13", "1.1.0-beta12")
-1

lydell avatar Mar 16 '24 10:03 lydell