Skip to content

Commit

Permalink
fix: remove/migrate plugins during updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jun 12, 2018
1 parent a4a9988 commit cad9523
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,20 @@ export default class Plugins {
}

async update() {
const plugins = (await this.list()).filter((p): p is Config.PJSON.PluginTypes.User => p.type === 'user')
let plugins = (await this.list()).filter((p): p is Config.PJSON.PluginTypes.User => p.type === 'user')
if (plugins.length === 0) return
cli.action.start(`${this.config.name}: Updating plugins`)

// migrate deprecated plugins
const aliases = this.config.pjson.oclif.aliases || {}
for (let [name, to] of Object.entries(aliases)) {
const plugin = plugins.find(p => p.name === name)
if (!plugin) continue
if (to) await this.install(to)
await this.uninstall(name)
plugins = plugins.filter(p => p.name !== name)
}

if (plugins.find(p => !!p.url)) {
await this.yarn.exec(['upgrade'], {cwd: this.config.dataDir, verbose: this.verbose})
}
Expand Down

0 comments on commit cad9523

Please sign in to comment.