Added commit Hash to home page
This commit is contained in:
parent
a37e31ec80
commit
e7c9f8d9c7
4 changed files with 17 additions and 2 deletions
|
|
@ -5,13 +5,25 @@
|
|||
var fs = require('fs');
|
||||
var browserify = require('browserify');
|
||||
var exec = require('child_process').exec;
|
||||
var shell = require('shelljs');
|
||||
|
||||
var puts = function(error, stdout, stderr) {
|
||||
if (error) console.log(error);
|
||||
};
|
||||
|
||||
var getCommitHash = function() {
|
||||
//exec git command to get the hash of the current commit
|
||||
//git rev-parse HEAD
|
||||
|
||||
var hash = shell.exec('git rev-parse HEAD').output.trim().substr(0,10);
|
||||
return hash;
|
||||
}
|
||||
|
||||
var createVersion = function() {
|
||||
var json = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
||||
var content = 'module.exports="' + json.version + '";';
|
||||
var content = 'module.exports.version="' + json.version + '";';
|
||||
|
||||
content = content + '\nmodule.exports.commitHash="' + getCommitHash() + '";';
|
||||
fs.writeFileSync("./version.js", content);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue