MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / writeNote

Function writeNote

apps/desktop/src/main/vault.ts:2652–2661  ·  view source on GitHub ↗
(root: string, rel: string, body: string)

Source from the content-addressed store, hash-verified

2650}
2651
2652export async function writeNote(root: string, rel: string, body: string): Promise<NoteMeta> {
2653 const abs = resolveSafe(root, rel)
2654 await fs.mkdir(path.dirname(abs), { recursive: true })
2655 await fs.writeFile(abs, body, 'utf8')
2656 invalidateNoteMetaCache(root, rel)
2657 invalidateVaultTextSearchCache(root)
2658 const folder = folderOf(root, abs)
2659 if (!folder) throw new Error(`Note not in a known folder: ${rel}`)
2660 return await readMeta(root, abs, folder)
2661}
2662
2663function normalizeNoteComment(input: NoteCommentInput, notePath: string): NoteComment | null {
2664 const body = typeof input.body === 'string' ? input.body.trim() : ''

Callers 6

vault.test.tsFile · 0.90
registerIpcFunction · 0.90
vault.perf.test.tsFile · 0.90
updateInboundWikilinksFunction · 0.70
cmdWriteFunction · 0.50

Calls 5

invalidateNoteMetaCacheFunction · 0.85
resolveSafeFunction · 0.70
folderOfFunction · 0.70
readMetaFunction · 0.70

Tested by

no test coverage detected