mirror of
https://github.com/LukeHagar/sveltekit-electron-adapter.git
synced 2025-12-07 20:57:44 +00:00
[Release] v0.2.0
This commit is contained in:
33
scripts/githash.ts
Normal file
33
scripts/githash.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import Logger from "@ptkdev/logger";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { execSync } from "child_process";
|
||||
import semver from "../package.json";
|
||||
|
||||
const gitdotfile = `${__dirname}/../.git/config`;
|
||||
const logger = new Logger();
|
||||
let branch = "";
|
||||
let hash = "";
|
||||
|
||||
const execSyncWrapper = (command: string) => {
|
||||
let stdout = "";
|
||||
try {
|
||||
stdout = execSync(command).toString().trim();
|
||||
} catch (error) {
|
||||
logger.error(JSON.stringify(error));
|
||||
}
|
||||
return stdout;
|
||||
};
|
||||
|
||||
if (fs.existsSync(gitdotfile)) {
|
||||
branch = execSyncWrapper("git rev-parse --abbrev-ref HEAD");
|
||||
hash = execSyncWrapper("git rev-parse --short=7 HEAD");
|
||||
}
|
||||
|
||||
const obj = {
|
||||
semver: semver.version.split("-")[0],
|
||||
branch,
|
||||
hash,
|
||||
};
|
||||
|
||||
fs.writeFileSync(path.resolve("app/configs", "version.json"), JSON.stringify(obj, null, "\t"));
|
||||
Reference in New Issue
Block a user