2022-01-02 01:54:57 +00:00
|
|
|
/* 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];
|
2022-01-04 00:04:27 +00:00
|
|
|
|
2022-01-02 01:54:57 +00:00
|
|
|
// 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);
|
2022-01-04 00:04:27 +00:00
|
|
|
await out.write((match ? line.replace(match[1], `"${match[1]}"`) : line) + "\n");
|
2022-01-02 01:54:57 +00:00
|
|
|
}
|
2022-01-04 00:04:27 +00:00
|
|
|
await out.close();
|
2022-01-02 01:54:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
processDefFile().catch((ex) => {
|
|
|
|
console.error('Failed to process def file!', ex);
|
|
|
|
process.exit(1);
|
|
|
|
})
|