mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
24 lines
702 B
TypeScript
24 lines
702 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",
|
|
});
|
|
await exited;
|
|
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);
|