mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
If src/codegen/create_hash_table can't be run due to some reason (e.g. due to missing Math::BigInt Perl module) the build continues but fails later, during bindings compilation, because the generated files are empty. Fix it by handling the failure to run create_hash_table properly. Closes #7074
28 lines
872 B
TypeScript
28 lines
872 B
TypeScript
import { spawn } from "bun";
|
|
import path from "path";
|
|
import { writeIfNotChanged } from "./helpers";
|
|
|
|
const input = process.argv[2];
|
|
const output = process.argv[3];
|
|
|
|
const create_hash_table = path.join(import.meta.dir, "./create_hash_table");
|
|
|
|
const { stdout, exited } = spawn({
|
|
cmd: [create_hash_table, input],
|
|
stdout: "pipe",
|
|
stderr: "inherit",
|
|
});
|
|
const procResult = await exited;
|
|
if (procResult.exitCode !== 0) {
|
|
console.log("Failed to generate " + output + ", create_hash_table exited with " + procResult);
|
|
process.exit(1);
|
|
}
|
|
let str = await new Response(stdout).text();
|
|
str = str.replaceAll(/^\/\/.*$/gm, "");
|
|
str = str.replaceAll(/^#include.*$/gm, "");
|
|
str = str.replaceAll(`namespace JSC {`, "");
|
|
str = str.replaceAll(`} // namespace JSC`, "");
|
|
str = "// File generated via `static-hash-table.ts`\n" + str.trim() + "\n";
|
|
|
|
writeIfNotChanged(output, str);
|