Skip to content
Semantic versioning for grunt
Latest commit a8f9b89 Sep 11, 2014 @mikaelkaron Merge pull request #4 from snowfix/feature/usage-instructions
Add usage instructions from reverse engineering of the code
Failed to load latest commit information.

Build Status NPM version


Semantic versioner for grunt

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-semver --save-dev

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:


The "grunt-semver" task


In your project's Gruntfile, add a section named semver to the data object passed into grunt.initConfig().

  "semver": {
    "options": {
      // Task-specific options go here.
      space: "\t"
    "your_target": {
      // Target-specific file lists and/or options go here.
      files: [{
          src: "package.json",
          dest: "package.json.out"
      }, { 
          src: "bower.json",
          dest: "bower.json.out"


Validate a string as a correct version according to semantic versionning:

$ grunt semver:validate:your_target:0.1.2

$ grunt semver:validate:your_target:0.1.2foo
Warning: Invalid Version: 0.1.2foo

Validate versions found if the given part's files:

$ grunt semver:your_target:validate
package.json : 0.1.2
bower.json : 0.1.2

Set given version in every files:

$ grunt semver:your_target:set:0.1.4
package.json : 0.1.4
bower.json : 0.1.4

Bump major/minor/patch/prerelease number (example starts at 0.1.2-pre.1):

$ grunt semver:your_target:validate
package.json : 0.1.2-pre.1
bower.json : 0.1.2-pre.1

$ grunt semver:your_target:bump:major
package.json : 1.0.0
bower.json : 1.0.0

$ grunt semver:your_target:bump:minor
package.json : 0.2.0
bower.json : 0.2.0

$ grunt semver:your_target:bump:patch
package.json : 0.1.3
bower.json : 0.1.3

$ grunt semver:your_target:bump:prerelease
package.json : 0.1.2-pre.2
bower.json : 0.1.2-pre.2```

Strip build or prerelease information (example starts at 0.1.2-pre.1+0123456)::

$ grunt semver:your_target:validate
package.json : 0.1.2-pre.1+0123456
bower.json : 0.1.2-pre.1+0123456

$ grunt semver:your_target:strip:prerelease
package.json : 0.1.2+0123456
bower.json : 0.1.2+0123456

$ grunt semver:your_target:strip:build
package.json : 0.1.2-pre.1
bower.json : 0.1.2-pre.1


Type: String
Default value: \t

A string value that is used to format the output JSON


In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

0.1.6 - Further cleanup. Added support for strip
0.1.5 - Externalize common code to separat modules
0.1.4 - Added support for cli arguments
0.1.3 - Added support for event 0.1.2 - Added verbose logging
0.1.1 - Added support for templated arguments
0.1.0 - First somewhat stable release
0.0.3 - Nothing to important
0.0.2 - Added support for build
0.0.1 - First release

Something went wrong with that request. Please try again.