Skip to content

Commit

Permalink
feat(version): increment version supports semver, close #34
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Dec 6, 2016
1 parent 294b802 commit c2eeb5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,22 @@ when running locally
//registry.npmjs.org/:_authToken=
[Error: Auth token for registry exists //registry.npmjs.org/:_authToken=]

### increment version
### increment or set package version

Runs `npm version [major | minor | patch]` command.
Runs `npm version [major | minor | patch | version]` command.

```js
incrementVersion({
increment: 'major|minor|patch',
increment: 'major|minor|patch|semver version',
noGit: true // default false = Git commit happens
})
// example
incrementVersion({
increment: '2.0.1'
})
```

See `npm help version` - but we only support increments, not absolute values.
See `npm help version`.

## Bin commands

Expand Down
4 changes: 3 additions & 1 deletion src/npm-increment-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ var isIncrement = is.oneOf(['major', 'minor', 'patch'])

function npmVersion (opts) {
la(is.object(opts), 'missing options')
la(isIncrement(opts.increment), 'invalid increment', opts)
la(isIncrement(opts.increment) ||
is.semver(opts.increment), 'invalid increment or version', opts)

var cmd = 'npm version ' + opts.increment
if (opts.noGit) {
cmd += ' --no-git-tag-version'
Expand Down

0 comments on commit c2eeb5e

Please sign in to comment.