1
0

refactor: 优化 clean 脚本,目录直接删除替代 glob 逐文件清理,补充 playwright-report/test-results

This commit is contained in:
2026-05-18 09:18:36 +08:00
parent 393e8da5fd
commit c51bc5a0d8

View File

@@ -3,13 +3,22 @@ import { resolve } from "node:path";
const root = resolve(import.meta.dir, ".."); const root = resolve(import.meta.dir, "..");
const patterns: Array<{ desc: string; glob: string }> = [ const dirs: Array<{ desc: string; path: string }> = [
{ desc: "构建产物", glob: "dist/**" }, { desc: "构建产物", path: "dist" },
{ desc: "Bun 构建缓存", glob: ".build/**" }, { desc: "Bun 构建缓存", path: ".build" },
{ desc: "Bun 构建临时文件", glob: ".*.bun-build" }, { desc: "Playwright 测试报告", path: "playwright-report" },
{ desc: "测试结果", path: "test-results" },
]; ];
for (const { desc, glob } of patterns) { const filePatterns: Array<{ desc: string; glob: string }> = [{ desc: "Bun 构建临时文件", glob: ".*.bun-build" }];
for (const { desc, path } of dirs) {
const full = resolve(root, path);
await rm(full, { force: true, recursive: true });
console.log(`已清理 ${desc}: ${path}`);
}
for (const { desc, glob } of filePatterns) {
const entries = await Array.fromAsync(new Bun.Glob(glob).scan({ cwd: root, dot: true })); const entries = await Array.fromAsync(new Bun.Glob(glob).scan({ cwd: root, dot: true }));
if (entries.length === 0) continue; if (entries.length === 0) continue;
for (const entry of entries) { for (const entry of entries) {