mirror of
https://github.com/talwrii/plugin-repl.git
synced 2026-07-22 11:40:27 +00:00
fix() -- Allow appending to empty files
This commit is contained in:
parent
79a4b2dddb
commit
be4935b6a4
1 changed files with 5 additions and 2 deletions
7
main.ts
7
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue