Skip to content

Commit

Permalink
Merge pull request #837 from oclif/mdonnalley/clear-legacy-commands
Browse files Browse the repository at this point in the history
fix: clear commands belonging to legacy plugins before reloading
  • Loading branch information
mdonnalley committed Oct 24, 2023
2 parents 4181c60 + c20c7ba commit 78051db
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,17 @@ export class Config implements IConfig {
private insertLegacyPlugins(plugins: IPlugin[]) {
for (const plugin of plugins) {
this.plugins.set(plugin.name, plugin)

// Delete all commands from the legacy plugin so that we can re-add them.
// This is necessary because this.determinePriority will pick the initial
// command that was added, which won't have been converted by PluginLegacy yet.
for (const cmd of plugin.commands ?? []) {
this._commands.delete(cmd.id)
for (const alias of [...(cmd.aliases ?? []), ...(cmd.hiddenAliases ?? [])]) {
this._commands.delete(alias)
}
}

this.loadCommands(plugin)
}
}
Expand Down

0 comments on commit 78051db

Please sign in to comment.