build.ts 559 B

123456789101112131415161718192021222324
  1. const COMMIT_ID: string = (() => {
  2. try {
  3. const childProcess = require("child_process");
  4. return childProcess
  5. .execSync('git log -1 --format="%at000" --date=unix')
  6. .toString()
  7. .trim();
  8. } catch (e) {
  9. console.error("[Build Config] No git or not from git repo.");
  10. return "unknown";
  11. }
  12. })();
  13. export const getBuildConfig = () => {
  14. if (typeof process === "undefined") {
  15. throw Error(
  16. "[Server Config] you are importing a nodejs-only module outside of nodejs",
  17. );
  18. }
  19. return {
  20. commitId: COMMIT_ID,
  21. };
  22. };