3 天以前 5f0032ef5c9cafb38352b823f5389e01c4306abb
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}`);