From d1522c97ea134a866c11ee317398fefa2beef11f Mon Sep 17 00:00:00 2001 From: Jonas Perusquia Morales Date: Wed, 28 Jan 2026 13:54:02 -0600 Subject: [PATCH] Make dist clean cross-platform without shell commands --- app/build.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/build.ts b/app/build.ts index 3fd35ef..c20526a 100644 --- a/app/build.ts +++ b/app/build.ts @@ -2,7 +2,7 @@ import { $ } from "bun"; import * as tsup from "tsup"; import pkg from "./package.json" with { type: "json" }; import c from "picocolors"; -import { watch as fsWatch } from "node:fs"; +import { watch as fsWatch, readdirSync, rmSync } from "node:fs"; import { join } from "node:path"; const args = process.argv.slice(2); @@ -27,7 +27,18 @@ const define = { if (clean) { console.info("Cleaning dist (w/o static)"); - await $`find dist -mindepth 1 ! -path "dist/static/*" ! -path "dist/static" -exec rm -rf {} +`; + // Cross-platform clean: remove all files/folders in dist except static + const distPath = join(import.meta.dir, "dist"); + try { + const entries = readdirSync(distPath); + for (const entry of entries) { + if (entry === "static") continue; + const entryPath = join(distPath, entry); + rmSync(entryPath, { recursive: true, force: true }); + } + } catch (e) { + // dist may not exist yet, ignore + } } let types_running = false;