(root: string, rel: string, text: string)
| 1092 | } |
| 1093 | |
| 1094 | export async function appendToNote(root: string, rel: string, text: string): Promise<NoteMeta> { |
| 1095 | const abs = resolveSafe(root, rel) |
| 1096 | const body = await fs.readFile(abs, 'utf8') |
| 1097 | const normalized = body.replace(/\r\n/g, '\n') |
| 1098 | const sep = normalized.endsWith('\n') || normalized.length === 0 ? '' : '\n' |
| 1099 | const next = normalized + sep + (normalized.length > 0 ? '\n' : '') + trimTrailingNewlines(text) + '\n' |
| 1100 | await fs.writeFile(abs, next, 'utf8') |
| 1101 | const folder = folderOf(root, abs) |
| 1102 | if (!folder) throw new Error(`Note not in a known folder: ${rel}`) |
| 1103 | return await readMeta(root, abs, folder) |
| 1104 | } |
| 1105 | |
| 1106 | export async function prependToNote(root: string, rel: string, text: string): Promise<NoteMeta> { |
| 1107 | const abs = resolveSafe(root, rel) |
no test coverage detected