1
0

feat: 添加 clean 脚本清理构建过程文件

This commit is contained in:
2026-05-09 15:29:52 +08:00
parent f723ecb1b5
commit 9267f6585c
2 changed files with 20 additions and 0 deletions

19
scripts/clean.ts Normal file
View File

@@ -0,0 +1,19 @@
import { readdir, rm } from "node:fs/promises";
import { resolve } from "node:path";
const root = resolve(import.meta.dir, "..");
const patterns: Array<{ glob: string; desc: string }> = [
{ glob: ".build/", desc: "Bun 构建缓存" },
{ glob: ".*.bun-build", desc: "Bun 构建临时文件" },
];
for (const { glob, desc } of patterns) {
const entries = await Array.fromAsync(new Bun.Glob(glob).scan({ root, dot: true }));
if (entries.length === 0) continue;
for (const entry of entries) {
const full = resolve(root, entry);
await rm(full, { recursive: true, force: true });
console.log(`已清理 ${desc}: ${entry}`);
}
}