From a255f3fa33723ac2e6030fef757e4ed1b080e48f Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 15 Mar 2026 16:32:56 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BC=98=E5=8C=96]=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=9D=99=E6=80=81=E5=AF=BC=E5=87=BA=E6=B5=81=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=87=8D=E5=91=BD=E5=90=8D=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BB=A5=E7=AE=80=E5=8C=96=E7=9B=AE=E5=BD=95=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/scripts/prepare-static-export.mjs | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/openflare_server/web/scripts/prepare-static-export.mjs b/openflare_server/web/scripts/prepare-static-export.mjs index 295d2654..c0c70322 100644 --- a/openflare_server/web/scripts/prepare-static-export.mjs +++ b/openflare_server/web/scripts/prepare-static-export.mjs @@ -1,14 +1,19 @@ -import { cpSync, existsSync, mkdirSync, rmSync } from 'node:fs'; -import { resolve } from 'node:path'; - -const root = process.cwd(); -const outDir = resolve(root, 'out'); -const buildDir = resolve(root, 'build'); +import { cpSync, existsSync, mkdirSync, renameSync, rmSync } from 'node:fs'; +import { resolve } from 'node:path'; + +const root = process.cwd(); +const outDir = resolve(root, 'out'); +const buildDir = resolve(root, 'build'); if (!existsSync(outDir)) { throw new Error('Missing Next.js export output: out/'); } - -rmSync(buildDir, { recursive: true, force: true }); -mkdirSync(buildDir, { recursive: true }); -cpSync(outDir, buildDir, { recursive: true }); + +rmSync(buildDir, { recursive: true, force: true }); + +try { + renameSync(outDir, buildDir); +} catch (error) { + mkdirSync(buildDir, { recursive: true }); + cpSync(outDir, buildDir, { recursive: true }); +}