Resolve one target against cwd, then the vault root. Files only.
(vault: string, target: string)
| 26 | |
| 27 | /** Resolve one target against cwd, then the vault root. Files only. */ |
| 28 | async function resolveTarget(vault: string, target: string): Promise<string | null> { |
| 29 | const candidates = [path.resolve(target)] |
| 30 | if (vault) candidates.push(path.resolve(vault, target)) |
| 31 | |
| 32 | for (const candidate of candidates) { |
| 33 | try { |
| 34 | const stat = await fsp.stat(candidate) |
| 35 | if (stat.isFile()) return candidate |
| 36 | } catch { |
| 37 | // try the next candidate |
| 38 | } |
| 39 | } |
| 40 | return null |
| 41 | } |
| 42 | |
| 43 | function assertMarkdown(abs: string): void { |
| 44 | if (!isMarkdownFilePath(abs)) { |