This may sound like a very basic question, but this is the first time I have to deal with something like this. Also, I tried to search, but I don't really know what to type as a search query.
I have this code:
function getGitInfo() {
var commit;
git.short(function (str) {
commit = str;
console.log("inner Commit Var: " + commit);
});
console.log("Outter Commit Var: " + commit);
return commit;
};
and i'm trying to get str
returned by getGitInfo()
function.
From the above code, in my console I get only the "inner commit var", with the right value, but I never get the outer one.
How can i return str so that in another variable i can just do:
var test = getGitInfo();
and have returned as test
the value from str
?
NB: this code uses git-rev node modules (git-rev)
Thanks, and sorry again for the stupid question :)