Semver, but where 'hotfix' pre-releases are treated as post-releases.
The semver spec allows for pre-lease versioning, but not post-release (hotfix) versioning.
This package provides semver utility functions that place -hotfix suffixes ahead of release versions in priority, so that the semver-strict sort order of:
+ 1.0.0
+ 1.0.0-alpha.0
+ 1.0.0-hotfix.3
Would become:
+ 1.0.0-hotfix.3
+ 1.0.0
+ 1.0.0-alpha.0
This package uses the same functions as semver package, implementing replacements where the hotfix interpretation matters (e.g. in comparisons) and serving as a pass-through where they do not.
Functions that would be impacted by the hotfix interpretation but that are not yet implemented here are not passed through to semver.
npm install @bscotch/semver-hotfix
Typescript:
``ts`
import {compare} from "@bscotch/semver-hotfix"
const toSort = [
"1.0.0".
"1.0.0-alpha.0".
"1.0.0-hotfix.3"
].sort(compare);
console.log(toSort);
// ['1.0.0-hotfix.3','1.0.0','1.0.0-alpha.0']
For regular Javascript/Node, you'll probably use const {compare} = require("@bscotch/semver-hotfix")
See the semver package for documentation, as this package serves as either a pass-through for functions in that package or re-implements them with the same arguments and output.
+ comparercompare
+ gt
+ gte
+ lt
+ lte
+
+ validinc
+ prerelease
+ major
+ minor
+ patch
+ parse
+
To get Typescript support for the pass-through functions, you'll need to run npm i -D @types/semver`.