-
-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathprebuild.ts
More file actions
33 lines (26 loc) · 946 Bytes
/
prebuild.ts
File metadata and controls
33 lines (26 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
console.log("Generating git-info.json");
import { $ } from "bun";
import { rmdir } from "fs/promises";
//check if git is available
$`git --version`.catch(() => {
console.warn("Git is not available. Skipping git-info.json generation.");
process.exit(0);
});
$`git rev-parse --abbrev-ref HEAD`.then((branch) => {
$`git rev-parse --short HEAD`.then((commit) => {
const gitInfo = {
branch: branch.text().trim(),
commit: commit.text().trim(),
};
Bun.file("src/git-info.json").write(JSON.stringify(gitInfo, null, 2));
console.log("git-info.json generated:", gitInfo);
});
});
console.log("Finished generating git-info.json");
// console.log("Clearing image fetch cache...");
// await rmdir(".next/cache/images", { recursive: true }).catch((err) => {
// if (err.code !== "ENOENT") {
// console.error("Failed to clear image fetch cache:", err);
// }
// });
// console.log("Image fetch cache cleared.");