Last active
April 11, 2023 20:04
-
-
Save thiskevinwang/2d805983d6745a666e24ee4fdaf53ea1 to your computer and use it in GitHub Desktop.
Semver Package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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