( config: any, basePath: string = '', )
| 68 | * @returns A new configuration object with file references resolved |
| 69 | */ |
| 70 | export async function processConfigFileReferences( |
| 71 | config: any, |
| 72 | basePath: string = '', |
| 73 | ): Promise<any> { |
| 74 | if (config === null || config === undefined) { |
| 75 | return config; |
| 76 | } |
| 77 | |
| 78 | // Handle string values with file:// protocol |
| 79 | if (typeof config === 'string' && config.startsWith('file://')) { |
| 80 | return await loadFileReference(config, basePath); |
| 81 | } |
| 82 | |
| 83 | // Handle arrays |
| 84 | if (Array.isArray(config)) { |
| 85 | const result = []; |
| 86 | for (const item of config) { |
| 87 | result.push(await processConfigFileReferences(item, basePath)); |
| 88 | } |
| 89 | return result; |
| 90 | } |
| 91 | |
| 92 | // Handle objects |
| 93 | if (typeof config === 'object') { |
| 94 | const result: Record<string, any> = {}; |
| 95 | for (const [key, value] of Object.entries(config)) { |
| 96 | result[key] = await processConfigFileReferences(value, basePath); |
| 97 | } |
| 98 | return result; |
| 99 | } |
| 100 | |
| 101 | // Return primitive values as is |
| 102 | return config; |
| 103 | } |
no test coverage detected
searching dependent graphs…