Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added syntax highlighting to readme example
  • Loading branch information
amilajack authored and isaacs committed Feb 8, 2017
1 parent 32802c5 commit aaba710
Showing 1 changed file with 47 additions and 37 deletions.
84 changes: 47 additions & 37 deletions README.md
@@ -1,55 +1,65 @@
semver(1) -- The semantic versioner for npm
===========================================

## Install

```bash
npm install --save semver
````

## Usage

$ npm install semver
$ node
var semver = require('semver')
As a node module:

```js
const semver = require('semver')
semver.valid('1.2.3') // '1.2.3'
semver.valid('a.b.c') // null
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
semver.valid('1.2.3') // '1.2.3'
semver.valid('a.b.c') // null
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
```

As a command-line utility:

$ semver -h
```
$ semver -h

SemVer 5.1.0
SemVer 5.3.0

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

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

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

-i --increment [<level>]
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.
-i --increment [<level>]
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>
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.
--preid <identifier>
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.

-l --loose
Interpret versions and ranges loosely
-l --loose
Interpret versions and ranges loosely

Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
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.
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.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.
```
## Versions
Expand Down Expand Up @@ -126,20 +136,20 @@ The method `.inc` takes an additional `identifier` string argument that
will append the value of the string as a prerelease identifier:
```javascript
> semver.inc('1.2.3', 'prerelease', 'beta')
'1.2.4-beta.0'
semver.inc('1.2.3', 'prerelease', 'beta')
// '1.2.4-beta.0'
```

command-line example:

```shell
```bash
$ semver 1.2.3 -i prerelease --preid beta
1.2.4-beta.0
```

Which then can be used to increment further:

```shell
```bash
$ semver 1.2.4-beta.0 -i prerelease
1.2.4-beta.1
```
Expand Down

0 comments on commit aaba710

Please sign in to comment.