Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: parent & child plugins (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
RasPhilCo authored Dec 21, 2018
1 parent 521c89d commit e0b5e95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export class Config implements IConfig {
} catch {}
return 0
}
protected async loadPlugins(root: string, type: string, plugins: (string | {root?: string, name?: string, tag?: string})[]) {
protected async loadPlugins(root: string, type: string, plugins: (string | {root?: string, name?: string, tag?: string})[], parent?: Plugin.Plugin) {
if (!plugins || !plugins.length) return
debug('loading plugins', plugins)
await Promise.all((plugins || []).map(async plugin => {
Expand All @@ -435,7 +435,11 @@ export class Config implements IConfig {
await instance.load()
if (this.plugins.find(p => p.name === instance.name)) return
this.plugins.push(instance)
await this.loadPlugins(instance.root, type, instance.pjson.oclif.plugins || [])
if (parent) {
instance.parent = parent
parent.children.push(instance)

This comment has been minimized.

Copy link
@tnoonan-salesforce

tnoonan-salesforce Dec 26, 2018

We are seeing cases in the sfdx-cli when parent.children is undefined.

}
await this.loadPlugins(instance.root, type, instance.pjson.oclif.plugins || [], instance)
} catch (err) {
this.warn(err, 'loadPlugins')
}
Expand Down
4 changes: 4 additions & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface Options {
tag?: string
ignoreManifest?: boolean,
errorOnManifestCreate?: boolean
parent?: Plugin
children?: Plugin[]
}

export interface IPlugin {
Expand Down Expand Up @@ -86,6 +88,8 @@ export class Plugin implements IPlugin {
hooks!: {[k: string]: string[]}
valid = false
alreadyLoaded = false
parent: Plugin | undefined
children: Plugin[] = []
protected _debug = Debug()
protected warned = false

Expand Down

0 comments on commit e0b5e95

Please sign in to comment.