build.ts 620 B

123456789101112131415161718192021222324252627
  1. const COMMIT_ID: string = (() => {
  2. try {
  3. const childProcess = require("child_process");
  4. return (
  5. childProcess
  6. // .execSync("git describe --tags --abbrev=0")
  7. .execSync("git rev-parse --short HEAD")
  8. .toString()
  9. .trim()
  10. );
  11. } catch (e) {
  12. console.error("[Build Config] No git or not from git repo.");
  13. return "unknown";
  14. }
  15. })();
  16. export const getBuildConfig = () => {
  17. if (typeof process === "undefined") {
  18. throw Error(
  19. "[Server Config] you are importing a nodejs-only module outside of nodejs",
  20. );
  21. }
  22. return {
  23. commitId: COMMIT_ID,
  24. };
  25. };