From fbb48eae788ec978074d179465cfe1a2d6c176cd Mon Sep 17 00:00:00 2001 From: Masoud Ghorbani Date: Sun, 5 Jan 2025 17:34:01 +0100 Subject: [PATCH 1/2] fix: improve code readability and exclude files from listInstalledPlugins function --- src/providers/plugins.ts | 13 ++++++++----- src/services/prune.ts | 7 ++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/providers/plugins.ts b/src/providers/plugins.ts index 37a676a..d3cffa4 100644 --- a/src/providers/plugins.ts +++ b/src/providers/plugins.ts @@ -19,7 +19,6 @@ export const removePluginDir = async (pluginId: string, vaultPath: string) => { childLogger.debug(`Remove plugin`) await rm(pluginDir, { recursive: true, force: true }) - await modifyCommunityPlugins({ id: pluginId }, vaultPath, 'disable') childLogger.debug(`Removed plugin`) } @@ -30,11 +29,15 @@ export const listInstalledPlugins = async (vaultPath: string) => { await access(pluginsPath, constants.R_OK) - const existingDirs = await readdir(pluginsPath) + const entries = await readdir(pluginsPath, { + withFileTypes: true, + }) - installedPlugins = existingDirs.map((plugin) => ({ - id: plugin, - })) + installedPlugins = entries + .filter(({ isDirectory }) => isDirectory()) + .map((dir) => ({ + id: dir.name, + })) return installedPlugins } diff --git a/src/services/prune.ts b/src/services/prune.ts index 9dd7025..d254269 100644 --- a/src/services/prune.ts +++ b/src/services/prune.ts @@ -1,6 +1,10 @@ import { ArgInput } from '@oclif/core/lib/parser' import { each } from 'async' -import { listInstalledPlugins, removePluginDir } from '../providers/plugins' +import { + listInstalledPlugins, + modifyCommunityPlugins, + removePluginDir, +} from '../providers/plugins' import { getSelectedVaults, mapVaultsIteratorItem } from '../providers/vaults' import { FactoryFlagsWithVaults, @@ -28,6 +32,7 @@ const pruneVaultIterator: PruneCommandIterator = async (item) => { for (const plugin of toBePruned) { await removePluginDir(plugin.id, vault.path) + await modifyCommunityPlugins({ id: plugin.id }, vault.path, 'disable') } childLogger.info(`Pruned ${toBePruned.length} plugins`, { From af3c8dc01009e93bd3753d257bf5d254639e4e04 Mon Sep 17 00:00:00 2001 From: Masoud Ghorbani Date: Sun, 5 Jan 2025 17:35:07 +0100 Subject: [PATCH 2/2] 0.6.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b9c06ec..aa0a601 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "ovm", "description": "Obsidian Vaults Manager", "type": "commonjs", - "version": "0.6.3", + "version": "0.6.4", "license": "GPL-3.0-only", "author": "Masoud Ghorbani", "homepage": "https://github.com/msudgh/ovm",