const fs = require('fs-extra'); const ch = require('child_process'); const SCENE = process.env.SCENE; fs.ensureDirSync('.temp'); fs.emptyDirSync('.temp'); const distDir = `build${!!SCENE ? '/' + SCENE : ''}`; ch.execSync(`npm run build${!!SCENE ? ':' + SCENE : ''}:test`, { stdio: ['ignore', 'inherit', 'inherit'], }); const distFiles = fs.readdirSync(distDir); // 静态资源默认不上传 const IGNORE_FILES = ['images', 'js', 'fonts']; if (!distFiles.length) throw new Error(`请先执行 yarn ${distDir}`); distFiles.forEach((fileName) => { if (!process.env.INCLUDE_STATIC && IGNORE_FILES.includes(fileName)) return; fs.copySync( `${distDir}/${fileName}`, `.temp/${fileName === 'resources' ? fileName : 'data/' + fileName}` ); });