spring
3 天以前 a35679754f3b2547bbbe5f2f6360cea31ff0433e
multiple/multiple-build.js
@@ -16,6 +16,7 @@
const rootPath = path.resolve(__dirname, '..');
const resourcePath = path.join(rootPath, 'multiple', 'assets');
const replacePath = path.join(rootPath, 'replace');
const replacedFiles = [];
// 获取命令行参数
const params = parseArgs(process.argv);
@@ -43,6 +44,7 @@
        await fs.mkdir(path.dirname(backupFile), { recursive: true });
        await fs.copyFile(originFile, backupFile);
        replacedFiles.push({ originFile, backupFile });
        await fs.copyFile(replaceFile, originFile);
    }
@@ -60,13 +62,10 @@
    // 恢复资源文件
    if (fsSync.existsSync(replacePath)) {
        for (const [key, value] of Object.entries(companyMap)) {
            if (key === 'env') continue;
            const originFile = path.join(rootPath, config[key]);
            const backupFile = path.join(replacePath, config[key]);
            await fs.copyFile(backupFile, originFile);
        for (const { originFile, backupFile } of replacedFiles) {
            if (fsSync.existsSync(backupFile)) {
                await fs.copyFile(backupFile, originFile);
            }
        }
        await fs.rm(replacePath, { recursive: true, force: true });
        console.log(`🗑️ 已删除 ${replacePath}`);