11/*!
2- * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
2+ * Copyright (c) 2023-2026 Digital Bazaar, Inc. All rights reserved.
33 */
44import { fileURLToPath } from 'node:url' ;
5- import fs from 'node:fs/promises ' ;
5+ import fs from 'node:fs' ;
66import path from 'node:path' ;
77
88const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
99
1010export const contextsDir = path . resolve ( __dirname , '..' , 'contexts' ) ;
1111export const credentialsDir = path . resolve ( __dirname , '..' , 'credentials' ) ;
12-
13- const entries = await fs . readdir ( credentialsDir , { withFileTypes : true } ) ;
12+ /**
13+ * TODO: Add an async `loadExamples()` API as additional surface.
14+ * - Should be idempotent (loads once, caches result).
15+ * - Sync loading remains for backward compatibility.
16+ */
17+ const entries = fs . readdirSync ( credentialsDir , { withFileTypes : true } ) ;
1418const credentialDirs = entries . filter ( e => e . isDirectory ( ) ) . map ( d => d . name ) ;
1519
1620const credentials = { } ;
@@ -23,14 +27,14 @@ for(const dirName of credentialDirs) {
2327 let queries = null ;
2428
2529 try {
26- const credText = await fs . readFile ( credentialJsonPath , 'utf8' ) ;
30+ const credText = fs . readFileSync ( credentialJsonPath , 'utf8' ) ;
2731 credential = JSON . parse ( credText ) ;
2832 } catch ( e ) {
2933 throw new Error ( `Failed to read/parse ${ credentialJsonPath } : ${ e . message } ` ) ;
3034 }
3135
3236 try {
33- const queriesText = await fs . readFile ( queriesJsonPath , 'utf8' ) ;
37+ const queriesText = fs . readFileSync ( queriesJsonPath , 'utf8' ) ;
3438 queries = JSON . parse ( queriesText ) ;
3539 } catch {
3640 // if queries.json is missing or invalid, keep as null
0 commit comments