huminmin
2026-06-01 a563ea879ef5fb6897e76d2df661e465dce2ab9b
multiple/multiple-build.js
@@ -24,19 +24,6 @@
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=======");
@@ -54,8 +41,9 @@
        const backupFile = path.join(replacePath, config[key]);
        const replaceFile = path.join(resourcePath, companyMap[key]);
        await copyFileWithOverwrite(originFile, backupFile);
        await copyFileWithOverwrite(replaceFile, originFile);
        await fs.mkdir(path.dirname(backupFile), { recursive: true });
        await fs.copyFile(originFile, backupFile);
        await fs.copyFile(replaceFile, originFile);
    }
    console.log("=====开始打包======");
@@ -78,7 +66,7 @@
            const originFile = path.join(rootPath, config[key]);
            const backupFile = path.join(replacePath, config[key]);
            await copyFileWithOverwrite(backupFile, originFile);
            await fs.copyFile(backupFile, originFile);
        }
        await fs.rm(replacePath, { recursive: true, force: true });
        console.log(`🗑️ 已删除 ${replacePath}`);