(dir: string, root: string, files: Set<string>)
| 549 | } |
| 550 | |
| 551 | async function walkFileBrowserFiles(dir: string, root: string, files: Set<string>): Promise<void> { |
| 552 | let entries; |
| 553 | try { |
| 554 | entries = await readdir(dir, { withFileTypes: true }); |
| 555 | } catch { |
| 556 | return; |
| 557 | } |
| 558 | |
| 559 | for (const entry of entries) { |
| 560 | const fullPath = join(dir, entry.name); |
| 561 | const relativePath = relative(root, fullPath).replace(/\\/g, "/"); |
| 562 | if (entry.isDirectory()) { |
| 563 | if (isFileBrowserExcludedPath(relativePath)) continue; |
| 564 | await walkFileBrowserFiles(fullPath, root, files); |
| 565 | } else if (entry.isFile() && FILE_BROWSER_EXTENSIONS.test(entry.name)) { |
| 566 | if (isFileBrowserExcludedPath(relativePath)) continue; |
| 567 | files.add(relativePath); |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | /** List markdown files in a directory as a nested tree. */ |
| 573 | export async function handleFileBrowserFiles(req: Request): Promise<Response> { |
no test coverage detected