Recursively count .md files under a given directory. Used to see * whether ` /inbox/` actually has content.
(dir: string)
| 86 | /** Recursively count .md files under a given directory. Used to see |
| 87 | * whether `<root>/inbox/` actually has content. */ |
| 88 | async function countMdFilesRecursively(dir: string): Promise<number> { |
| 89 | let entries: import('node:fs').Dirent[] |
| 90 | try { |
| 91 | entries = await fs.readdir(dir, { withFileTypes: true }) |
| 92 | } catch { |
| 93 | return 0 |
| 94 | } |
| 95 | let count = 0 |
| 96 | for (const entry of entries) { |
| 97 | if (entry.name.startsWith('.')) continue |
| 98 | const full = path.join(dir, entry.name) |
| 99 | if (entry.isDirectory()) count += await countMdFilesRecursively(full) |
| 100 | else if (entry.isFile() && entry.name.toLowerCase().endsWith('.md')) count += 1 |
| 101 | } |
| 102 | return count |
| 103 | } |
| 104 | |
| 105 | /** Decide whether this vault uses inbox-mode or root-mode for its |
| 106 | * primary notes area. The vault's on-disk layout is the strongest |
no outgoing calls
no test coverage detected