(dir: string, base: string)
| 576 | } |
| 577 | |
| 578 | async function uniqueTitle(dir: string, base: string): Promise<string> { |
| 579 | let candidate = base |
| 580 | let n = 1 |
| 581 | while (true) { |
| 582 | try { |
| 583 | await fs.access(path.join(dir, `${candidate}.md`)) |
| 584 | n += 1 |
| 585 | candidate = `${base} ${n}` |
| 586 | } catch { |
| 587 | return candidate |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | function sanitizeTitle(raw: string): string { |
| 593 | // Filenames must be safe on all 3 OSes. Strip path separators, null, |
no outgoing calls
no test coverage detected