Skip to content

Commit

Permalink
More updates for published Obsidian standards.
Browse files Browse the repository at this point in the history
  • Loading branch information
TfT Hacker committed Oct 27, 2024
1 parent 710dbac commit 3094892
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions src/features/BetaPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion src/utils/internetconnection.ts
Original file line number Diff line number Diff line change
@@ -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<boolean> {
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;
Expand Down
14 changes: 7 additions & 7 deletions src/utils/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit 3094892

Please sign in to comment.