Skip to content

Commit c94db68

Browse files
plugin startup library fix
1 parent ea46d5f commit c94db68

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "circuit-sketcher",
33
"name": "Circuit Sketcher",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"minAppVersion": "0.15.0",
66
"description": "Draw circuits on a canvas using circuit-sketcher-core.",
77
"author": "Code Forge Temple",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "circuit-sketcher-obsidian-plugin",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"main": "main.js",
55
"author": "Code Forge Temple",
66
"license": "GPL",

src/main.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,18 @@ export default class CircuitSketcherPlugin extends Plugin {
9090
}
9191

9292
public async getLibraryFile (): Promise<string> {
93+
const NEW_LIBRARY_CONTENT = "{}";
94+
9395
if (!(await this.app.vault.adapter.exists(this.settings.libraryPath))) {
9496
try {
95-
await this.app.vault.create(this.settings.libraryPath, "");
97+
await this.app.vault.create(this.settings.libraryPath, NEW_LIBRARY_CONTENT);
9698
} catch { /*ignore*/}
9799
}
98100

99101
const libraryFile = this.app.vault.getAbstractFileByPath(this.settings.libraryPath);
100102

101103
if (libraryFile instanceof TFile) {
102-
return await this.app.vault.read(libraryFile);
104+
return (await this.app.vault.read(libraryFile)) || NEW_LIBRARY_CONTENT;
103105
}
104106

105107
throw new Error("Library file is not a valid TFile");

0 commit comments

Comments
 (0)