From be4935b6a4e062efb25b53817fdb298295458e8a Mon Sep 17 00:00:00 2001 From: Tal Wrii Date: Fri, 3 Jan 2025 06:05:44 +0100 Subject: [PATCH] fix() -- Allow appending to empty files --- main.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.ts b/main.ts index 5afee34..314ef3e 100644 --- a/main.ts +++ b/main.ts @@ -272,10 +272,13 @@ async function writeFile(app: any, name: string, text: string) { } async function appendToFile(app: App, name: string, appended: string) { - let existing = await readFile(app, name) - if (existing === undefined) { + let existing + if (!await app.vault.exists(name + ".md")) { existing = "" + } else { + existing = await readFile(app, name) } + const content = existing + appended await writeFile(app, name, content) }