@@ -49,22 +49,9 @@ export function parseKDL(kdlText: string) {
49
49
/**
50
50
* Recursively collect all KDL file URLs in a directory.
51
51
*/
52
- async function getAllKDLFileURLs ( folder : URL , file : string ) : Promise < URL [ ] > {
52
+ async function getAllKDLFileURLs ( folder : URL ) : Promise < URL [ ] > {
53
53
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 ) ) ;
68
55
}
69
56
70
57
/**
@@ -78,9 +65,9 @@ export async function readInputKDL(fileUrl: URL): Promise<any> {
78
65
/**
79
66
* Read, parse, and merge all KDL files under the input folder.
80
67
*/
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 ) ;
84
71
85
72
const parsedContents = await Promise . all ( fileUrls . map ( readInputKDL ) ) ;
86
73
0 commit comments