api: use version-info package & clean up start message
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
import { execSync } from "child_process";
|
||||
|
||||
let commit, commitInfo, branch;
|
||||
|
||||
export function shortCommit() {
|
||||
if (commit) return commit;
|
||||
let c = execSync('git rev-parse --short HEAD').toString().trim();
|
||||
commit = c;
|
||||
return c
|
||||
}
|
||||
export function getCommitInfo() {
|
||||
if (commitInfo) return commitInfo;
|
||||
let d = execSync(`git show -s --format='%s;;;%B'`).toString().trim().replace(/[\r\n]/gm, '\n').split(';;;');
|
||||
d[1] = d[1].replace(d[0], '').trim().toString().replace(/[\r\n]/gm, '<br>');
|
||||
commitInfo = d;
|
||||
return d
|
||||
}
|
||||
export function getCurrentBranch() {
|
||||
if (branch) return branch;
|
||||
let b = execSync('git branch --show-current').toString().trim();
|
||||
branch = b;
|
||||
return b
|
||||
}
|
||||
@@ -7,6 +7,10 @@ const root = join(
|
||||
'../../'
|
||||
);
|
||||
|
||||
export function loadFile(path) {
|
||||
return fs.readFileSync(join(root, path), 'utf-8')
|
||||
}
|
||||
|
||||
export function loadJSON(path) {
|
||||
try {
|
||||
return JSON.parse(loadFile(path))
|
||||
@@ -14,7 +18,3 @@ export function loadJSON(path) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function loadFile(path) {
|
||||
return fs.readFileSync(join(root, path), 'utf-8')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user