( directoryPath: string, fileSystemExecutor: FileSystemExecutor, )
| 235 | } |
| 236 | |
| 237 | async function collectSwiftFiles( |
| 238 | directoryPath: string, |
| 239 | fileSystemExecutor: FileSystemExecutor, |
| 240 | ): Promise<string[]> { |
| 241 | const entries = await listDirectoryEntries(directoryPath, fileSystemExecutor); |
| 242 | if (entries.length === 0) { |
| 243 | return []; |
| 244 | } |
| 245 | |
| 246 | const entryPaths = entries.map((entry) => path.join(directoryPath, entry)); |
| 247 | const statResults = await Promise.all( |
| 248 | entryPaths.map(async (fullPath) => { |
| 249 | try { |
| 250 | const stats = await fileSystemExecutor.stat(fullPath); |
| 251 | return { fullPath, isDir: stats.isDirectory() }; |
| 252 | } catch { |
| 253 | return null; |
| 254 | } |
| 255 | }), |
| 256 | ); |
| 257 | |
| 258 | const files: string[] = []; |
| 259 | const subdirPromises: Array<Promise<string[]>> = []; |
| 260 | |
| 261 | for (const result of statResults) { |
| 262 | if (!result) { |
| 263 | continue; |
| 264 | } |
| 265 | if (result.isDir) { |
| 266 | subdirPromises.push(collectSwiftFiles(result.fullPath, fileSystemExecutor)); |
| 267 | } else if (result.fullPath.endsWith('.swift')) { |
| 268 | files.push(result.fullPath); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | const nestedFiles = await Promise.all(subdirPromises); |
| 273 | return files.concat(...nestedFiles); |
| 274 | } |
| 275 | |
| 276 | async function resolveCandidateDirectories( |
| 277 | reference: ReferencedTestTarget, |
no test coverage detected