mirror of
https://github.com/remko/waforth
synced 2024-12-27 09:59:29 +01:00
22 lines
490 B
JavaScript
Executable file
22 lines
490 B
JavaScript
Executable file
#!/usr/bin/env node
|
|
|
|
const process = require("process");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
const infn = process.argv[2];
|
|
const outfn = process.argv[3];
|
|
|
|
const name = path
|
|
.basename(outfn)
|
|
.split(".")
|
|
.slice(0, -1)
|
|
.join(".")
|
|
.replace(/-/g, "_");
|
|
const inf = fs.readFileSync(infn);
|
|
const bs = [];
|
|
for (const b of inf) {
|
|
bs.push(`0x${b.toString(16)}`);
|
|
}
|
|
const out = `static unsigned char ${name}[] = { ${bs.join(", ")} };\n`;
|
|
fs.writeFileSync(outfn, out);
|