Check the global git config to ensure its setup

This commit is contained in:
Nick O'Leary
2018-01-24 21:05:48 +00:00
parent 64607df929
commit 7a89e3cf33
4 changed files with 54 additions and 12 deletions

View File

@@ -369,11 +369,27 @@ module.exports = {
init: function(_settings,_runtime) {
log = _runtime.log
return new Promise(function(resolve,reject) {
runGitCommand(["--version"]).then(function(output) {
var m = / (\d\S+)/.exec(output);
Promise.all([
runGitCommand(["--version"]),
runGitCommand(["config","--global","user.name"]).catch(err=>""),
runGitCommand(["config","--global","user.email"]).catch(err=>"")
]).then(function(output) {
var m = / (\d\S+)/.exec(output[0]);
gitVersion = m[1];
resolve(gitVersion);
var globalUserName = output[1].trim();
var globalUserEmail = output[2].trim();
var result = {
version: gitVersion
};
if (globalUserName && globalUserEmail) {
result.user = {
name: globalUserName,
email: globalUserEmail
}
}
resolve(result);
}).catch(function(err) {
console.log(err);
resolve(null);
});
});