diff --git a/src/config/config.ts b/src/config/config.ts index 3adb495dc..527deef21 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -294,6 +294,10 @@ export class Config implements IConfig { await search(module).call(context, {...opts as any, config: this}) final.successes.push({plugin: p, result}) + if (p.name === '@oclif/plugin-legacy' && event === 'init') { + this.insertLegacyPlugins(result as IPlugin[]) + } + debug('done') } catch (error: any) { final.failures.push({plugin: p, error: error as Error}) @@ -729,6 +733,14 @@ export class Config implements IConfig { }) return commandPlugins[0] } + + 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) + this.loadCommands(plugin) + } + } } // when no manifest exists, the default is calculated. This may throw, so we need to catch it