show git revision
This commit is contained in:
@@ -1,6 +1,18 @@
|
||||
import * as docx from "docx";
|
||||
import cookie from "cookie";
|
||||
import fs from "fs";
|
||||
import { execSync } from "child_process";
|
||||
|
||||
function getGitRevision() {
|
||||
// get git revision and branch
|
||||
try {
|
||||
const revision = execSync("git rev-parse --short HEAD").toString().trim();
|
||||
const branch = execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
|
||||
return { revision, branch };
|
||||
} catch (e) {
|
||||
return { revision: "unknown", branch: "unknown" };
|
||||
}
|
||||
}
|
||||
|
||||
function createDirectoryIfNotExists(dirPath) {
|
||||
if (!fs.existsSync(dirPath)) {
|
||||
@@ -97,4 +109,4 @@ function createEvent(event, data) {
|
||||
return `event: ${event}\ndata: ${data}\n\n`;
|
||||
}
|
||||
|
||||
export { createEvent, createDirectoryIfNotExists, sleep, extractCookie, getSessionCookie, createDocx };
|
||||
export { createEvent, createDirectoryIfNotExists, sleep, extractCookie, getSessionCookie, createDocx, getGitRevision };
|
||||
|
||||
Reference in New Issue
Block a user