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", 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`, {