Cheap one-line summary of a directory: `(N items)`. Best-effort; failure → empty.
(dir: string)
| 194 | |
| 195 | /** Cheap one-line summary of a directory: `(N items)`. Best-effort; failure → empty. */ |
| 196 | async function summariseDir(dir: string): Promise<string> { |
| 197 | try { |
| 198 | const items = await fs.readdir(dir); |
| 199 | const visible = items.filter(n => !IGNORED_DIRS.has(n) && !IGNORED_FILES.has(n) && !n.startsWith('.')); |
| 200 | return `(${visible.length} item${visible.length === 1 ? '' : 's'})`; |
| 201 | } catch { |
| 202 | return ''; |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | function pushLine(line: string, ctx: TreeContext): void { |
| 207 | ctx.lines.push(line); |