Takes a version number string of the form 'major.minor.build' and increments it, wrapping the build number but not the minor number. Includes a separate method for incrementing the major number.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
LICENSE
README.md
package.json
version-incrementer.js

README.md

version-incrementer

Takes a version number string of the form 'major.minor.build' and increments it, wrapping the build number but not the minor number. Includes a separate method for incrementing the major number.

The build & minor numbers are incremented according to the following rules:

  • It will wrap the build number after 9, incrementing the minor number.
  • It won't wrap the minor number (ie. '10' is okay).
  • It won't wrap the major number (there's a separate method for that).

If the input isn't in the form x.y.z then it will just return the value that you pass in.

Inspired by mparke's increment-version, but works off a string rather than a file.

Example

$ node
> var increment = require('version-incrementer').increment;
undefined
> increment('0.5.7');
'0.5.8'
> increment('0.5.9');
'0.6.0'
> var incrementMajor = require('version-incrementer').incrementMajor;
undefined
> incrementMajor('0.5.9');
'1.0.0'
> incrementMajor('3.5.1');
'4.0.0'

Tests are included.

Installation

npm install version-incrementer

License

MIT