core: fix patch

This commit is contained in:
undefined committed 2023-04-22 21:50:19 +08:00
1 parent d55cf5ae45
commit d8d1776260
1 file changed
+5 -4
+5 -4
View File
@@ -15,16 +15,17 @@ export function register(cli: CAC) {
return;
}
logger.info('Patching %s', mod);
const res = await superagent.get(patch);
const res = await superagent.get(patch).responseType('arraybuffer');
logger.info('Downloaded patch');
for (let i = 0; i <= 100; i++) {
const fp = path.join(path.dirname(mod), `${mod}.${i}.patch`);
const fp = path.join(path.dirname(mod), `${path.basename(mod)}.${i}.patch`);
if (fs.existsSync(fp)) continue;
patch = fp;
break;
}
await fs.writeFile(patch, res.text);
child.execSync(`patch ${mod} -o ${mod} < ${patch}`);
await fs.writeFile(patch, res.body);
child.execSync(`patch ${mod} -o ${mod}.tmp < ${patch}`);
await fs.move(`${mod}.tmp`, mod);
logger.info('Patched %s', mod);
});