forked from XiaoMo/ChatGPT-Next-Web
6264c02543
release workflow
29 lines
736 B
TypeScript
29 lines
736 B
TypeScript
export const getBuildConfig = () => {
|
|
if (typeof process === "undefined") {
|
|
throw Error(
|
|
"[Server Config] you are importing a nodejs-only module outside of nodejs",
|
|
);
|
|
}
|
|
|
|
const COMMIT_ID: string = (() => {
|
|
try {
|
|
const childProcess = require("child_process");
|
|
return childProcess
|
|
.execSync('git log -1 --format="%at000" --date=unix')
|
|
.toString()
|
|
.trim();
|
|
} catch (e) {
|
|
console.error("[Build Config] No git or not from git repo.");
|
|
return "unknown";
|
|
}
|
|
})();
|
|
|
|
return {
|
|
commitId: COMMIT_ID,
|
|
buildMode: process.env.BUILD_MODE ?? "standalone",
|
|
isApp: !!process.env.BUILD_APP,
|
|
};
|
|
};
|
|
|
|
export type BuildConfig = ReturnType<typeof getBuildConfig>;
|