| 348 | } |
| 349 | |
| 350 | async function walkFiles(rootDir, visitFile) { |
| 351 | const stack = [rootDir] |
| 352 | |
| 353 | while (stack.length > 0) { |
| 354 | const current = stack.pop() |
| 355 | const entries = await fs.readdir(current, { withFileTypes: true }) |
| 356 | |
| 357 | for (const entry of entries) { |
| 358 | const fullPath = path.join(current, entry.name) |
| 359 | |
| 360 | if (entry.isDirectory()) { |
| 361 | if (!SEARCH_SKIP_DIRS.has(entry.name)) { |
| 362 | stack.push(fullPath) |
| 363 | } |
| 364 | continue |
| 365 | } |
| 366 | |
| 367 | if (!entry.isFile()) { |
| 368 | continue |
| 369 | } |
| 370 | |
| 371 | const shouldContinue = await visitFile(fullPath) |
| 372 | if (shouldContinue === false) { |
| 373 | return |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | function resolveWorkspacePath(workspaceDir, requestedPath) { |
| 380 | const absoluteWorkspace = path.resolve(workspaceDir) |