Skip to content

Commit f39257b

Browse files
committed
use require() to read json
1 parent edea223 commit f39257b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/fetcher.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as fs from "fs";
2+
import * as path from "path";
23
import fetch from "node-fetch";
34
import { JSDOM } from "jsdom";
45

@@ -10,11 +11,10 @@ interface IDLSource {
1011
}
1112

1213
async function fetchIDLs() {
13-
const file = fs.readFileSync(`${__dirname}/../inputfiles/idlSources.json`, { encoding: "utf-8" });
14-
const idlSources = JSON.parse(file) as IDLSource[];
14+
const idlSources = require("../inputfiles/idlSources.json") as IDLSource[];
1515
for (const source of idlSources) {
1616
const idl = await fetchIDL(source);
17-
fs.writeFileSync(`${__dirname}/../inputfiles/idl/${source.title}.widl`, idl + '\n');
17+
fs.writeFileSync(path.join(__dirname, `../inputfiles/idl/${source.title}.widl`), idl + '\n');
1818
}
1919
}
2020

0 commit comments

Comments
 (0)