(
config: Configuration,
configPath: string,
processedIncludePaths?: Set<string>,
processedIncludeEntries?: WeakSet<ConfigurationDirective>
)
| 106 | } |
| 107 | |
| 108 | async function resolveConfigIncludes( |
| 109 | config: Configuration, |
| 110 | configPath: string, |
| 111 | processedIncludePaths?: Set<string>, |
| 112 | processedIncludeEntries?: WeakSet<ConfigurationDirective> |
| 113 | ): Promise<void> { |
| 114 | processedIncludePaths = processedIncludePaths ?? new Set<string>(); |
| 115 | processedIncludeEntries = processedIncludeEntries ?? new WeakSet<ConfigurationDirective>(); |
| 116 | const configKey: string = getProcessedPathKey(configPath); |
| 117 | if (processedIncludePaths.has(configKey)) { |
| 118 | return; |
| 119 | } |
| 120 | processedIncludePaths.add(configKey); |
| 121 | try { |
| 122 | for (const entry of config) { |
| 123 | if (isDirective(entry) && entry.param === 'Include') { |
| 124 | // Prevent duplicate expansion of the same Include directive within a single resolution pass. |
| 125 | if (processedIncludeEntries.has(entry)) { |
| 126 | continue; |
| 127 | } |
| 128 | processedIncludeEntries.add(entry); |
| 129 | let includePath: string = resolveHome(entry.value); |
| 130 | if (isWindows && !!includePath.match(/^\/[a-z]:/i)) { |
| 131 | includePath = includePath.slice(1); |
| 132 | } |
| 133 | |
| 134 | if (!path.isAbsolute(includePath)) { |
| 135 | includePath = path.resolve(path.dirname(configPath), includePath); |
| 136 | } |
| 137 | |
| 138 | const pathsToGetFilesFrom: string[] = await globAsync(includePath); |
| 139 | |
| 140 | for (const filePath of pathsToGetFilesFrom) { |
| 141 | const includeKey: string = getProcessedPathKey(filePath); |
| 142 | if (processedIncludePaths.has(includeKey)) { |
| 143 | continue; |
| 144 | } |
| 145 | await getIncludedConfigFile(config, filePath, processedIncludePaths, processedIncludeEntries); |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | } finally { |
| 150 | processedIncludePaths.delete(configKey); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | async function getIncludedConfigFile( |
| 155 | config: Configuration, |
no test coverage detected