Skip to content

Commit c2eeb5e

Browse files
committed
feat(version): increment version supports semver, close #34
1 parent 294b802 commit c2eeb5e

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,22 @@ when running locally
145145
//registry.npmjs.org/:_authToken=
146146
[Error: Auth token for registry exists //registry.npmjs.org/:_authToken=]
147147

148-
### increment version
148+
### increment or set package version
149149

150-
Runs `npm version [major | minor | patch]` command.
150+
Runs `npm version [major | minor | patch | version]` command.
151151

152152
```js
153153
incrementVersion({
154-
increment: 'major|minor|patch',
154+
increment: 'major|minor|patch|semver version',
155155
noGit: true // default false = Git commit happens
156156
})
157+
// example
158+
incrementVersion({
159+
increment: '2.0.1'
160+
})
157161
```
158162

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

161165
## Bin commands
162166

src/npm-increment-version.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ var isIncrement = is.oneOf(['major', 'minor', 'patch'])
77

88
function npmVersion (opts) {
99
la(is.object(opts), 'missing options')
10-
la(isIncrement(opts.increment), 'invalid increment', opts)
10+
la(isIncrement(opts.increment) ||
11+
is.semver(opts.increment), 'invalid increment or version', opts)
12+
1113
var cmd = 'npm version ' + opts.increment
1214
if (opts.noGit) {
1315
cmd += ' --no-git-tag-version'

0 commit comments

Comments
 (0)