diff --git a/CHANGELOG.md b/CHANGELOG.md index bc6178f..ab9c222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ ### Updates - Transition to Biome from EsLint and Prettier. - Updating plugint to newest Obsidian recommendations https://docs.obsidian.md/oo24/plugin - +- The output log file format for when debugging is enabled in BRAT has changed. It now appends to the log file, not prepends. # 1.0.3 diff --git a/src/features/BetaPlugins.ts b/src/features/BetaPlugins.ts index 3c9ab7e..5a3a5b6 100644 --- a/src/features/BetaPlugins.ts +++ b/src/features/BetaPlugins.ts @@ -175,11 +175,7 @@ export default class BetaPlugins { `${this.plugin.app.vault.configDir}/plugins/${betaPluginId}`, )}/`; const { adapter } = this.plugin.app.vault; - if ( - !(await adapter.exists(pluginTargetFolderPath)) || - !(await adapter.exists(`${pluginTargetFolderPath}manifest.json`)) - ) { - // if plugin folder doesnt exist or manifest.json doesn't exist, create it and save the plugin files + if (!(await adapter.exists(pluginTargetFolderPath))) { await adapter.mkdir(pluginTargetFolderPath); } await adapter.write( diff --git a/src/utils/internetconnection.ts b/src/utils/internetconnection.ts index c25f9de..30da1fa 100644 --- a/src/utils/internetconnection.ts +++ b/src/utils/internetconnection.ts @@ -1,10 +1,12 @@ +import { requestUrl } from "obsidian"; + /** * Tests if there is an internet connection * @returns true if connected, false if no internet */ export async function isConnectedToInternet(): Promise { try { - const online = await fetch(`https://obsidian.md/?${Math.random()}`); + const online = await requestUrl(`https://obsidian.md/?${Math.random()}`); return online.status >= 200 && online.status < 300; } catch (err) { return false; diff --git a/src/utils/logging.ts b/src/utils/logging.ts index 1936e37..0e3e123 100644 --- a/src/utils/logging.ts +++ b/src/utils/logging.ts @@ -24,13 +24,13 @@ export async function logger( const dateOutput = `[[${moment().format(getDailyNoteSettings().format).toString()}]] ${moment().format("HH:mm")}`; const os = window.require("os") as { hostname: () => string }; const machineName = Platform.isDesktop ? os.hostname() : "MOBILE"; - let output = `${dateOutput} ${machineName} ${textToLog.replace("\n", " ")}\n\n`; + const output = `${dateOutput} ${machineName} ${textToLog.replace("\n", " ")}\n`; - if (await plugin.app.vault.adapter.exists(fileName)) { - const fileContents = await plugin.app.vault.adapter.read(fileName); - output = output + fileContents; - const file = plugin.app.vault.getAbstractFileByPath(fileName) as TFile; - await plugin.app.vault.modify(file, output); - } else await plugin.app.vault.create(fileName, output); + let file = plugin.app.vault.getAbstractFileByPath(fileName) as TFile; + if (!file) { + file = await plugin.app.vault.create(fileName, output); + } else { + await plugin.app.vault.append(file, output); + } } }