Skip to content

bushee/git-tag-version

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Getting Started

npm install git-tag-version --save-dev

Once the module has been installed, just load it in your node project:

var gitVersion = require('git-tag-version');

Usage

gitVersion(options);

Parameter options is optional. It may contain these options:

  • uniqueSnapshot (default = false)
    if false, snapshot versions will be suffixed with just -SNAPSHOT, e.g. 1.0.0-SNAPSHOT; otherwise, current human-readable timestamp will be appended as well, e.g. 1.0.0-SNAPSHOT.20170920104533123

Examples

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"
console.log(gitVersion()); // will print "0.1.0"
touch file2.js
git add file2.js
git commit -m "add file2.js"
console.log(gitVersion()); // will print "0.1.1-SNAPSHOT"
console.log(gitVersion({uniqueSnapshot: true})); // will print something like "0.1.1-SNAPSHOT.20170920104533123"
git tag -a v0.1.1 -m "v0.1.1"
console.log(gitVersion()); // will print "0.1.1"

CLI

An npm cli task is also available; it's options are exactly the same as JS version.

git-tag-version [--uniqueSnapshot | --unique-snapshot]

Contributing

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%