( root: string, dir: string, out: PluginCommandEntry[], )
| 360 | } |
| 361 | |
| 362 | async function walkMarkdown( |
| 363 | root: string, |
| 364 | dir: string, |
| 365 | out: PluginCommandEntry[], |
| 366 | ): Promise<void> { |
| 367 | let entries; |
| 368 | try { |
| 369 | entries = await readdir(dir, { withFileTypes: true }); |
| 370 | } catch { |
| 371 | return; |
| 372 | } |
| 373 | for (const entry of entries) { |
| 374 | const full = path.join(dir, entry.name); |
| 375 | if (entry.isDirectory()) { |
| 376 | await walkMarkdown(root, full, out); |
| 377 | } else if (entry.isFile() && entry.name.endsWith('.md')) { |
| 378 | out.push({ path: full, name: commandNameFromFile(full, root) }); |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | function commandNameFromFile(file: string, root: string): string { |
| 384 | const relative = path.relative(root, file).replace(/\.md$/i, ''); |
no test coverage detected