From c51bc5a0d8ebc26120c833b1bbaaa574453eab2e Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Mon, 18 May 2026 09:18:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=20clean=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E7=9B=AE=E5=BD=95=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=9B=BF=E4=BB=A3=20glob=20=E9=80=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=B8=85=E7=90=86=EF=BC=8C=E8=A1=A5=E5=85=85?= =?UTF-8?q?=20playwright-report/test-results?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/clean.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/clean.ts b/scripts/clean.ts index d562591..59e30ec 100644 --- a/scripts/clean.ts +++ b/scripts/clean.ts @@ -3,13 +3,22 @@ import { resolve } from "node:path"; const root = resolve(import.meta.dir, ".."); -const patterns: Array<{ desc: string; glob: string }> = [ - { desc: "构建产物", glob: "dist/**" }, - { desc: "Bun 构建缓存", glob: ".build/**" }, - { desc: "Bun 构建临时文件", glob: ".*.bun-build" }, +const dirs: Array<{ desc: string; path: string }> = [ + { desc: "构建产物", path: "dist" }, + { desc: "Bun 构建缓存", path: ".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 })); if (entries.length === 0) continue; for (const entry of entries) {