LinuxCommandLibrary

semver

Semantic version string parser.

TLDR

Check if a version string respects the semantic versioning format (prints an empty string if it does not match)

$ semver [1.2]
copy


Convert a version string to the semantic versioning format
$ semver --coerce [1.2]
copy


Test if 1.2.3 matches the ^1.0 range (prints an empty string if it does not match)
$ semver [1.2.3] --range "[^1.0]"
copy


Test with multiple ranges
$ semver [1.2.3] --range [">=1.0"] ["<2.0"]
copy


Test multiple version strings and return only the ones that match
$ semver [1.2.3] [2.0.0] --range "[^1.0]"
copy

Help

SemVer 7.3.5 

A JavaScript implementation of the https://semver.org/ specification 
Copyright Isaac Z. Schlueter 

Usage: semver [options]  [ [...]] 
Prints valid versions sorted by SemVer precedence 

Options:
-r --range  
        Print versions that match the specified range. 

-i --increment [
        Increment a version by the specified level.  Level can 
        be one of: major, minor, patch, premajor, preminor, 
        prepatch, or prerelease.  Default level is 'patch'. 
        Only one version may be specified. 

--preid  
        Identifier to be used to prefix premajor, preminor, 
        prepatch or prerelease version increments. 

-l --loose 
        Interpret versions and ranges loosely 

-p --include-prerelease 
        Always include prerelease versions in range matching 

-c --coerce 
        Coerce a string into SemVer if possible 
        (does not imply --loose) 

--rtl 
        Coerce version strings right to left 

--ltr 
        Coerce version strings left to right (default) 

Program exits successfully if any valid version satisfies 
all supplied ranges, and prints all satisfying versions. 

If no satisfying versions are found, then exits failure. 

Versions are printed in ascending order, so supplying 
multiple versions to the utility will just sort them. 

Copied to clipboard