From 2bee81442387717d425ffde1dea3d2e9c4b7a00e Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期一, 11 五月 2026 16:47:01 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_NEW_pro' into dev_NEW_pro

---
 multiple/multiple-build.js |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/multiple/multiple-build.js b/multiple/multiple-build.js
index 8e078e1..d87b333 100644
--- a/multiple/multiple-build.js
+++ b/multiple/multiple-build.js
@@ -24,6 +24,19 @@
 
 const envFilePath = path.join(process.cwd(), '.env.production.local');
 
+async function copyFileWithOverwrite(src, dest) {
+    await fs.mkdir(path.dirname(dest), { recursive: true });
+    if (fsSync.existsSync(dest)) {
+        try {
+            await fs.chmod(dest, 0o666);
+        } catch {
+            // Ignore chmod failure and try delete directly.
+        }
+        await fs.rm(dest, { force: true });
+    }
+    await fs.copyFile(src, dest);
+}
+
 try {
     // 1锔忊儯 鐢熸垚 .env
     console.log("=======鐢熸垚.env=======");
@@ -41,9 +54,8 @@
         const backupFile = path.join(replacePath, config[key]);
         const replaceFile = path.join(resourcePath, companyMap[key]);
 
-        await fs.mkdir(path.dirname(backupFile), { recursive: true });
-        await fs.copyFile(originFile, backupFile);
-        await fs.copyFile(replaceFile, originFile);
+        await copyFileWithOverwrite(originFile, backupFile);
+        await copyFileWithOverwrite(replaceFile, originFile);
     }
 
     console.log("=====寮�濮嬫墦鍖�======");
@@ -66,7 +78,7 @@
             const originFile = path.join(rootPath, config[key]);
             const backupFile = path.join(replacePath, config[key]);
 
-            await fs.copyFile(backupFile, originFile);
+            await copyFileWithOverwrite(backupFile, originFile);
         }
         await fs.rm(replacePath, { recursive: true, force: true });
         console.log(`馃棏锔� 宸插垹闄� ${replacePath}`);

--
Gitblit v1.9.3