Skip to content

Commit

Permalink
fix: create .gitignore if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Oct 18, 2022
1 parent 79a1e86 commit ac8e3ee
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,15 @@ export default class ObsidianGit extends Plugin {
id: 'edit-gitignore',
name: 'Edit .gitignore',
callback: async () => {
const content = await this.app.vault.adapter.read(this.gitManager.getVaultPath(".gitignore"));
const path = this.gitManager.getVaultPath(".gitignore");
if (! await this.app.vault.adapter.exists(path)) {
this.app.vault.adapter.write(path, "");
}
const content = await this.app.vault.adapter.read(path);
const modal = new IgnoreModal(this.app, content);
const res = await modal.open();
if (res !== undefined) {
await this.app.vault.adapter.write(this.gitManager.getVaultPath(".gitignore"), res);
await this.app.vault.adapter.write(path, res);
this.refresh();
}
},
Expand Down

0 comments on commit ac8e3ee

Please sign in to comment.