Created
March 24, 2015 01:36
-
-
Save ryankurte/9a692ef07924f653ac82 to your computer and use it in GitHub Desktop.
Node.js git version module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var exec = require('child_process').exec; | |
var semver = require('semver'); | |
function update() { | |
var child = exec('git describe --dirty', function (error, stdout, stderr) { | |
exports.string = stdout.replace('\n', '').replace('\r', ''); | |
if(error) { | |
console.log(error); | |
exports.string = "Git Version Error"; | |
return; | |
} | |
if(semver.valid(exports.string)) { | |
exports.clean = semver.clean(exports.string); | |
exports.major = semver.major(exports.string); | |
exports.minor = semver.minor(exports.string); | |
exports.patch = semver.patch(exports.string); | |
} else { | |
console.log("No semantic version tag found"); | |
} | |
}); | |
}; | |
update(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment