What I'm trying now is to use shelljs, but for some reason shell.exec('git rev-parse HEAD') just hangs.
This is my code:
function getLatestCommit() {
return shell.exec("git rev-parse HEAD", {
silent: true,
}).output.trim().substr(0, 7);
}
Does anyone know any other way to achieve this?
I'm working on windows...
shell.exec
uses a callback. You're passing a parameter to it, but not utilizing the callback:
var shell = require('child_process');
function getLatestCommit() {
shell.exec("git rev-parse HEAD", { silent: true }, function(error, stdout, stderr) {
console.log(error, stdout);
});
}
getLatestCommit();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.