node-pty
node-pty copied to clipboard
Fix beta versioning
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-beta1happens to work as expected.^1.1.0-beta2on the other hand matches1.1.0-beta2to1.1.0-beta9and then1.1.0-beta20, but not1.1.0-beta10to1.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