Isaac Z. Schlueter, who is not looking for work, btw, has released a Semver library for Node.js. An extraction from his popular npm package manager for Node.js, node-semver parses version numbers in the Semantic Versioning format advocated by GitHub founder Tom Preston-Warner.
As expected, you can install via npm:
$ npm install semver
You can then use in your Node apps:
semver.valid('1.2.3') // true semver.valid('a.b.c') // false semver.clean(' =v1.2.3 ') // '1.2.3' semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true semver.gt('1.2.3', '9.8.7') // false semver.lt('1.2.3', '9.8.7') // true
… or from the command line with the included
semver command line utility:
$ semver -h Usage: semver -v <version> [-r <range>] Test if version(s) satisfy the supplied range(s), and sort them. Multiple versions or ranges may be supplied. Program exits successfully if any valid version satisfies all supplied ranges, and prints all satisfying versions. If no versions are valid, or ranges are not satisfied, then exits failure. Versions are printed in ascending order, so supplying multiple versions to the utility will just sort them.
Have comments? Send a tweet to @TheChangelog on Twitter.
Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.