Skip to content

Commit

Permalink
added semicolons where required
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktau committed Feb 10, 2024
1 parent a993938 commit deadd0c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/debouncedProcessors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { debounce, Debouncer, MarkdownPostProcessorContext, Menu, Notice, TFile } from "obsidian"
import { v4 as uuidv4 } from "uuid"
import PlantumlPlugin from "./main"
import { Processor } from "./processor"
import { debounce, Debouncer, MarkdownPostProcessorContext, Menu, Notice, TFile } from "obsidian";
import { v4 as uuidv4 } from "uuid";
import PlantumlPlugin from "./main";
import { Processor } from "./processor";

export class DebouncedProcessors implements Processor {

Expand Down Expand Up @@ -140,14 +140,14 @@ export class DebouncedProcessors implements Processor {
}

const getFolder = async () => {
let exportPath = this.plugin.settings.exportPath
let exportPath = this.plugin.settings.exportPath;
if (!exportPath.startsWith('/')) {
// relative to the document
const documentPath = this.plugin.app.vault.getAbstractFileByPath(ctx.sourcePath).parent;
exportPath = `${documentPath.path}/${exportPath}`
exportPath = `${documentPath.path}/${exportPath}`;
}

const exists = await this.plugin.app.vault.adapter.exists(exportPath)
const exists = await this.plugin.app.vault.adapter.exists(exportPath);
if (!exists) {
this.plugin.app.vault.createFolder(exportPath);
}
Expand All @@ -167,10 +167,10 @@ export class DebouncedProcessors implements Processor {

let fName = fileName;
if (fName.startsWith('/')) {
fName = fName.substring(1)
fName = fName.substring(1);
}

const folderOrFile = this.plugin.app.vault.getAbstractFileByPath(fName)
const folderOrFile = this.plugin.app.vault.getAbstractFileByPath(fName);

if (folderOrFile instanceof TFile) {
return folderOrFile as TFile;
Expand All @@ -183,10 +183,10 @@ export class DebouncedProcessors implements Processor {
if (img) {
renderToBlob(img, 'An error occurred while exporting the diagram', async (blob) => {
const filename = await getFilePath('png');
const buffer = await blob.arrayBuffer()
const file = getFile(filename)
const buffer = await blob.arrayBuffer();
const file = getFile(filename);
if (file) {
await this.plugin.app.vault.modifyBinary(file, buffer)
await this.plugin.app.vault.modifyBinary(file, buffer);
} else {
await this.plugin.app.vault.createBinary(filename, buffer);
}
Expand All @@ -198,16 +198,16 @@ export class DebouncedProcessors implements Processor {
const saveTextFile = async (type: string, data: string) => {
try {
const filename = await getFilePath(type);
const file = getFile(filename)
const file = getFile(filename);
if (file) {
await this.plugin.app.vault.modify(file, data);
} else {
await this.plugin.app.vault.create(filename, data)
await this.plugin.app.vault.create(filename, data);
}
new Notice(`Diagram exported to '${filename}'`);
} catch (error) {
new Notice('An error occurred while while exporting the diagram');
console.error(error)
console.error(error);
}
}

Expand Down

0 comments on commit deadd0c

Please sign in to comment.