(dir: string, baseTitle: string)
| 2811 | } |
| 2812 | |
| 2813 | export async function uniqueTitle(dir: string, baseTitle: string): Promise<string> { |
| 2814 | let candidate = baseTitle |
| 2815 | let n = 1 |
| 2816 | while (true) { |
| 2817 | try { |
| 2818 | await fs.access(path.join(dir, `${candidate}.md`)) |
| 2819 | n += 1 |
| 2820 | candidate = `${baseTitle} ${n}` |
| 2821 | } catch { |
| 2822 | return candidate |
| 2823 | } |
| 2824 | } |
| 2825 | } |
| 2826 | |
| 2827 | async function uniqueFilename(dir: string, filename: string): Promise<string> { |
| 2828 | const ext = path.extname(filename) |
no outgoing calls
no test coverage detected