Path: blob/main/scripts/update-interface-data.js
6476 views
import fs from "node:fs/promises";1import path from "node:path";23if (!process.argv[2]) {4console.error("Required argument: path to webref checkout");5process.exit(2);6}78const webrefPath = path.join(process.argv[2], "ed");9const idlnames = await fs10.readFile(path.join(webrefPath, "idlnames.json"), "utf-8")11.then(JSON.parse);1213const idls = await Promise.all(14Object.entries(idlnames)15.sort(([k1], [k2]) => k1.localeCompare(k2))16.map(([, { parsed: jsonIdlPath }]) =>17fs.readFile(path.join(webrefPath, jsonIdlPath), "utf-8").then(JSON.parse)18)19);2021const interfaceData = idls.reduce((interfaceData, idl) => {22if (idl.type === "interface") {23interfaceData[idl.name] = {24inh: idl.inheritance?.name || "",25impl: [],26};27}28return interfaceData;29}, {});3031await fs.writeFile(32"files/jsondata/InterfaceData.json",33JSON.stringify([interfaceData], null, 2) + "\n"34);353637