Keep the bin executable when it's not bundled

This commit is contained in:
Joseph Garrone
2024-05-19 08:36:33 +02:00
parent 4e72bc3a72
commit 8ed3561a55
3 changed files with 100 additions and 78 deletions

View File

@ -37,6 +37,16 @@ transformCodebase({
fs.rmSync(join("dist", "ncc_out"), { "recursive": true });
{
const before = fs.readFileSync(join("dist", "bin", "main.js")).toString("utf8");
const after = before.replace(`var buffer = new Buffer(toRead);`, `var buffer = Buffer.allocUnsafe(toRead);`);
assert(after !== before);
fs.writeFileSync(join("dist", "bin", "main.js"), Buffer.from(after, "utf8"));
}
fs.chmodSync(
join("dist", "bin", "main.js"),
fs.statSync(join("dist", "bin", "main.js")).mode | fs.constants.S_IXUSR | fs.constants.S_IXGRP | fs.constants.S_IXOTH