(browser, outputDir)
| 80 | |
| 81 | // 基于唯一的 apps/manifest.json 生成目标浏览器的 manifest 并写入 outputDir |
| 82 | function buildManifest(browser, outputDir) { |
| 83 | const srcPath = path.resolve('apps/manifest.json'); |
| 84 | const base = JSON.parse(fs.readFileSync(srcPath, 'utf-8')); |
| 85 | const patcher = BROWSER_PATCHES[browser]; |
| 86 | if (!patcher) throw new Error(`Unknown browser target: ${browser}`); |
| 87 | const finalManifest = patcher(base); |
| 88 | fs.writeFileSync(path.join(outputDir, 'manifest.json'), JSON.stringify(finalManifest)); |
| 89 | } |
| 90 | |
| 91 | // 清理输出目录 |
| 92 | function cleanOutput(outputDir = 'output-chrome') { |
no test coverage detected