Increments a version number string.


Takes a version number string of the form '' 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.

$ node
> var increment = require('version-incrementer').increment;
> increment('0.5.7');
> increment('0.5.9');
> var incrementMajor = require('version-incrementer').incrementMajor;
> incrementMajor('0.5.9');
> incrementMajor('3.5.1');

Tests are included.

npm install version-incrementer