2015-03-06 07:00:10 -08:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var fs = require('fs');
|
|
|
|
var shell = require('shelljs');
|
|
|
|
|
|
|
|
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', {
|
|
|
|
silent: true
|
|
|
|
}).output.trim().substr(0, 7);
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
var commitHash = getCommitHash();
|
|
|
|
|
2016-08-10 13:35:40 -07:00
|
|
|
|
|
|
|
var appConfig = JSON.parse(fs.readFileSync('./appConfig.json', 'utf8'));
|
|
|
|
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
|
|
|
|
|
|
|
console.log('v' + pkg.version + ' #' + commitHash + ' App:' + appConfig.name);
|
|
|
|
|
|
|
|
|
|
|
|
var content = 'window.version="' + pkg.version + '";';
|
2015-03-06 07:00:10 -08:00
|
|
|
content = content + '\nwindow.commitHash="' + commitHash + '";';
|
2016-08-10 13:35:40 -07:00
|
|
|
|
|
|
|
content = content + '\nwindow.appConfig=' + JSON.stringify(appConfig) + ';';
|
|
|
|
fs.writeFileSync("./src/js/appConfig.js", content);
|
2015-03-06 07:00:10 -08:00
|
|
|
|