fix() -- Allow appending to empty files

This commit is contained in:
Tal Wrii 2025-01-03 06:05:44 +01:00
parent 79a4b2dddb
commit be4935b6a4

View file

@ -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)
}