主题
获取当前 git HEAD sha1 hash 截取8位
fs 的一些操作
javascript
const execSync = require("child_process").execSync; //同步子进程
function getHash() {
//git sha1 hash 截取8位
const hash = execSync("git show -s --format=%H")
.toString()
.trim()
.slice(0, 8);
return hash;
}
const hash = getHash();
console.log("hash: ", hash);