hookshot/scripts/definitions-fixer.ts
Will Hunt 4388930a15
Switch to build script (#121)
* Switch to build script

* temp: export the result of the types build

* changelog

* Get output result

* Remove debug code

* Fix warning visibility

* Move the web build between the rust steps.

* Add debugging again

* Close file, and await promises

* drop the dumb cat
2022-01-04 00:04:27 +00:00

22 lines
694 B
TypeScript

/* eslint-disable no-console */
// Workaround to https://github.com/napi-rs/napi-rs/issues/986
import { promises as fs } from "fs";
async function processDefFile() {
const path = process.argv[process.argv.length-1];
// Read the whole file in to prevent us writing over ourselves.
const file = await fs.readFile(path, "utf-8");
const out = await fs.open(path, 'w');
for (const line of file.split('\n')) {
const match = / {2}(\w+\.[\w.-]+):/g.exec(line);
await out.write((match ? line.replace(match[1], `"${match[1]}"`) : line) + "\n");
}
await out.close();
}
processDefFile().catch((ex) => {
console.error('Failed to process def file!', ex);
process.exit(1);
})