Skip to content

Commit

Permalink
fix: support legacy plugins (#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley authored Feb 16, 2023
1 parent f78ae24 commit aff9e56
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit aff9e56

Please sign in to comment.