Calculate project version from git tags.
npm install git-tag-version> Calculate project version from git tags.
This module provides a function that calculates and returns project's current version based on git tags.
It is very useful when you need to calculate your project version in CI or deployment plans.
This moudle has been based on and is a more generalised (framework-agnostic) version of grunt-release-plugin by Jerzy Jelinek.
``shell`
npm install git-tag-version --save-dev
Once the module has been installed, just load it in your node project:
`js`
var gitVersion = require('git-tag-version');
`js`
gitVersion(options);
Parameter options is optional. It may contain these options:uniqueSnapshot
- (default = false)\-SNAPSHOT
if false, snapshot versions will be suffixed with just , e.g. 1.0.0-SNAPSHOT;1.0.0-SNAPSHOT.20170920104533123
otherwise, current human-readable timestamp will be appended as well, e.g.
`shell`
git init
touch file.js
git add file.js
git commit -m "add file.js"
git tag -a v0.1.0 -m "v0.1.0"
`js`
console.log(gitVersion()); // will print "0.1.0"
`shell`
touch file2.js
git add file2.js
git commit -m "add file2.js"
`js`
console.log(gitVersion()); // will print "0.1.1-SNAPSHOT"
console.log(gitVersion({uniqueSnapshot: true})); // will print something like "0.1.1-SNAPSHOT.20170920104533123"
`shell`
git tag -a v0.1.1 -m "v0.1.1"
`js`
console.log(gitVersion()); // will print "0.1.1"
`bash``
git-tag-version [--uniqueSnapshot | --unique-snapshot]