display git hash/branch

v1.18.x
barisusakli 9 years ago
parent 178281440e
commit 8d0cb18b74

@ -1,6 +1,8 @@
'use strict';
var async = require('async');
var os = require('os');
var exec = require('child_process').exec;
var infoController = {};
@ -18,12 +20,36 @@ infoController.get = function(req, res, next) {
uptime: process.uptime()
},
os: {
hostname: os.hostname()
hostname: os.hostname(),
type: os.type(),
platform: os.platform(),
arch: os.arch(),
release: os.release()
}
};
res.render('admin/development/info', {info: JSON.stringify(data, null, 4)});
getGitInfo(function(err, gitInfo) {
if (err) {
return next(err);
}
data.git = gitInfo;
res.render('admin/development/info', {info: JSON.stringify(data, null, 4)});
});
};
function getGitInfo(callback) {
function get(cmd, callback) {
exec(cmd, function(err, stdout) {
callback(err, stdout ? stdout.replace(/\n$/, '') : '');
});
}
async.parallel({
hash: function(next) {
get('git rev-parse HEAD', next);
},
branch: function(next) {
get('git rev-parse --abbrev-ref HEAD', next);
}
}, callback);
}
module.exports = infoController;
Loading…
Cancel
Save