Skip to content

Commit 2d3d3e4

Browse files
committed
-
1 parent 16c4f14 commit 2d3d3e4

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

src/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async function emitDom() {
9898
const deprecatedInfo = await readInputJSON("deprecatedMessage.json");
9999
const documentationFromMDN = await generateDescriptions();
100100
const removedItems = await readInputJSON("removedTypes.jsonc");
101-
const addedItemsKDL = await readKDL("addedTypes.kdl");
101+
const addedItemsKDL = await readKDL("patches");
102102

103103
async function readInputJSON(filename: string) {
104104
const content = await fs.readFile(new URL(filename, inputFolder), "utf8");

src/build/patches.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,9 @@ export function parseKDL(kdlText: string) {
4949
/**
5050
* Recursively collect all KDL file URLs in a directory.
5151
*/
52-
async function getAllKDLFileURLs(folder: URL, file: string): Promise<URL[]> {
52+
async function getAllKDLFileURLs(folder: URL): Promise<URL[]> {
5353
const entries = await readdir(folder, { withFileTypes: true });
54-
55-
const results: URL[] = [];
56-
57-
for (const entry of entries) {
58-
const child = new URL(entry.name + "/", folder);
59-
60-
if (entry.isDirectory()) {
61-
results.push(...(await getAllKDLFileURLs(child, file)));
62-
} else if (entry.isFile() && entry.name == file) {
63-
results.push(new URL(entry.name, folder));
64-
}
65-
}
66-
67-
return results;
54+
return entries.map((entry) => new URL(entry.name, folder));
6855
}
6956

7057
/**
@@ -78,9 +65,9 @@ export async function readInputKDL(fileUrl: URL): Promise<any> {
7865
/**
7966
* Read, parse, and merge all KDL files under the input folder.
8067
*/
81-
export default async function readKDL(file: string): Promise<any> {
82-
const inputFolder = new URL("../../inputfiles/patches/", import.meta.url);
83-
const fileUrls = await getAllKDLFileURLs(inputFolder, file);
68+
export default async function readKDL(folder: string): Promise<any> {
69+
const inputFolder = new URL(`../../inputfiles/${folder}/`, import.meta.url);
70+
const fileUrls = await getAllKDLFileURLs(inputFolder);
8471

8572
const parsedContents = await Promise.all(fileUrls.map(readInputKDL));
8673

0 commit comments

Comments
 (0)