aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/create-hash-table.ts
blob: 0d9b08d4130d01fba95acf00e440135766d6ea31 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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);