Skip to content

Commit

Permalink
fix: support legacy plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Feb 16, 2023
1 parent 4ed3ff7 commit 1b67627
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@oclif/core",
"description": "base library for oclif CLIs",
"version": "1.26.1",
"version": "1.26.2",
"author": "Salesforce",
"bugs": "https://github.com/oclif/core/issues",
"dependencies": {
Expand Down
12 changes: 12 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,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 @@ -745,6 +749,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 1b67627

Please sign in to comment.