Skip to content

Instantly share code, notes, and snippets.

@thiskevinwang
Last active April 11, 2023 20:04
Show Gist options
  • Save thiskevinwang/2d805983d6745a666e24ee4fdaf53ea1 to your computer and use it in GitHub Desktop.
Save thiskevinwang/2d805983d6745a666e24ee4fdaf53ea1 to your computer and use it in GitHub Desktop.
Semver Package
// run on runkit: https://runkit.com/embed/igg9vk09v684
const semver = require('semver')
semver.clean("v1.5.0-alpha20230405") // "1.5.0-alpha20230405"
semver.prerelease('v1.5.0-alpha20230405') // ["alpha20230405"]
semver.prerelease('v1.5.0-beta.1') // ["beta", 1]
semver.prerelease('v1.5.0-rc.1') // ["rc", 1]
semver.prerelease('v1.5.0-rc1') // ["rc1"]
const ver = semver.coerce("v1.5.x") // Semver Obj ("1.5.0")
semver
.inc(ver, "minor") // "1.6.0"
.replace(/(\d+\.\d+)\.\d+/, '$1.x') // "1.6.x"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment