Skip to content

Commit

Permalink
Merge 283ff2a into 6069fe7
Browse files Browse the repository at this point in the history
  • Loading branch information
b-bly committed Jul 22, 2018
2 parents 6069fe7 + 283ff2a commit 1061d78
Show file tree
Hide file tree
Showing 7 changed files with 550 additions and 439 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
coverage/
.nyc_output/
.idea
.vscode/launch.json
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/bin/semver",
"args": [
"-i", "prerelease",
"--preid", "dev",
"-n", "0",
"1.2.0"

]
}
]
}

25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,19 @@ Options:
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.

-n <identifier number base>
This is the number base to be used for the
prerelease identifier. Zero-based or one-based.

-l --loose
Interpret versions and ranges loosely

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



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

Expand Down Expand Up @@ -160,6 +166,25 @@ $ semver 1.2.4-beta.0 -i prerelease
1.2.4-beta.1
```

#### Prerelease Identifier Index

The method `.inc` takes an optional parameter 'identifierIndex' string
that will let you let your prerelease number as zero-based or one-based.
If you do not specify this parameter, it will default to zero-based.

```javascript
semver.inc('1.2.3', 'prerelease', 'beta', '1')
// '1.2.4-beta.1'
```

command-line example:

```bash
$ semver 1.2.3 -i prerelease --preid beta -n 1
1.2.4-beta.1
```


### Advanced Range Syntax

Advanced range syntax desugars to primitive comparators in
Expand Down
5 changes: 4 additions & 1 deletion bin/semver
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var argv = process.argv.slice(2)
, loose = false
, coerce = false
, identifier = undefined
, identifierIndex = undefined
, semver = require("../semver")
, reverse = false

Expand Down Expand Up @@ -55,6 +56,8 @@ function main () {
case "-r": case "--range":
range.push(argv.shift())
break
case "-n":
identifierIndex = argv.shift();
case "-c": case "--coerce":
coerce = true
break
Expand Down Expand Up @@ -98,7 +101,7 @@ function success () {
}).map(function (v) {
return semver.clean(v, loose)
}).map(function (v) {
return inc ? semver.inc(v, inc, loose, identifier) : v
return inc ? semver.inc(v, inc, loose, identifier, identifierIndex) : v
}).forEach(function (v,i,_) { console.log(v) })
}

Expand Down
Loading

0 comments on commit 1061d78

Please sign in to comment.