Skip to content

Commit

Permalink
fix: correctly load legacy plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed Jun 15, 2023
1 parent a2efc04 commit ec221d3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -805,10 +805,24 @@ export class Config implements IConfig {
return commandPlugins[0]
}

/**
* Insert legacy plugins
*
* Replace invalid CLI plugins (cli-engine plugins, mostly Heroku) loaded via `this.loadPlugins`
* with oclif-compatible ones returned by @oclif/plugin-legacy init hook.
*
* @param plugins array of oclif-compatible plugins
* @returns void
*/
private insertLegacyPlugins(plugins: IPlugin[]) {
for (const plugin of plugins) {
const idx = this.plugins.findIndex(p => p.name === plugin.name)
if (idx !== -1) this.plugins = this.plugins.splice(idx, 1, plugin)
if (idx !== -1) {
// invalid plugin instance found in `this.plugins`
// replace with the oclif-compatible one
this.plugins.splice(idx, 1, plugin)
}

this.loadCommands(plugin)
}
}
Expand Down

0 comments on commit ec221d3

Please sign in to comment.