diff --git a/src/commands/plugins/install.ts b/src/commands/plugins/install.ts index 8b876f99..bf1e28b7 100644 --- a/src/commands/plugins/install.ts +++ b/src/commands/plugins/install.ts @@ -1,5 +1,5 @@ /* eslint-disable no-await-in-loop */ -import {Args, Command, Errors, Flags, Interfaces, ux} from '@oclif/core' +import {Args, Command, Errors, Flags, Interfaces, Plugin, ux} from '@oclif/core' import {bold, cyan} from 'ansis' import validate from 'validate-npm-package-name' @@ -195,6 +195,12 @@ Use the <%= config.scopedEnvVarKey('NPM_REGISTRY') %> environment variable to se throw error } + const pluginInstance = new Plugin(plugin) + await pluginInstance.load() + this.config.plugins.set(pluginInstance.name, pluginInstance) + + await this.config.runHook('plugins:postinstall', {}) + ux.action.stop(`installed v${plugin.version}`) } } diff --git a/src/commands/plugins/uninstall.ts b/src/commands/plugins/uninstall.ts index 66766130..6dd076f8 100644 --- a/src/commands/plugins/uninstall.ts +++ b/src/commands/plugins/uninstall.ts @@ -48,6 +48,8 @@ export default class PluginsUninstall extends Command { logLevel: determineLogLevel(this.config, flags, 'silent'), }) + const pluginNameToDelete: string[] = [] + if (argv.length === 0) argv.push('.') for (const plugin of argv as string[]) { const friendly = removeTags(plugins.friendlyName(plugin)) @@ -64,9 +66,10 @@ export default class PluginsUninstall extends Command { try { const {name} = unfriendly - const displayName = friendly === '.' ? name : friendly ?? name + const displayName = friendly === '.' ? name : (friendly ?? name) ux.action.start(`${this.config.name}: Uninstalling ${displayName}`) await plugins.uninstall(name) + pluginNameToDelete.push(name) } catch (error) { ux.action.stop(bold.red('failed')) throw error @@ -74,5 +77,11 @@ export default class PluginsUninstall extends Command { ux.action.stop() } + + for (const p of pluginNameToDelete) { + this.config.plugins.delete(p) + } + + await this.config.runHook('plugins:postuninstall', {}) } }