1 | var _child_process = require("child_process");
|
2 | const tryExec = (command, option) => {
|
3 | try {
|
4 | return (0, _child_process.execSync)(command, option).toString();
|
5 | } catch (error) {
|
6 | console.warn(`[tryExec] failed for: ${command}, error: ${error}`);
|
7 | return "";
|
8 | }
|
9 | };
|
10 | exports.tryExec = tryExec;
|
11 | exports.getGitBranch = (() => tryExec("git symbolic-ref --short HEAD", {
|
12 | stdio: "pipe"
|
13 | }).replace("\n", "").trim());
|
14 | exports.getGitCommitHash = (() => tryExec('git log -1 --format="%H"', {
|
15 | stdio: "pipe"
|
16 | }).replace("\n", "").trim()); |
\ | No newline at end of file |