Skip to content

Commit

Permalink
fix: correct behavior of plugins retrieval functions (#1316)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmakhack committed Oct 24, 2020
1 parent b76bb03 commit 2291eab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/plugins/src/PluginsContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ export class PluginsContainer {
return this.plugins[name] as T;
}

byType<T extends Plugin>(type?: string): T[] {
if (!type) {
return Object.values(this.plugins) as T[];
}

byType<T extends Plugin>(type: string): T[] {
return Object.values(this.plugins).filter((pl: Plugin) => pl.type === type) as T[];
}

all<T extends Plugin>(): T[] {
return Object.values(this.plugins) as T[];
}

register(...args: any): void {
const [plugins, options] = normalizeArgs(args);
assign(plugins, options, this.plugins);
Expand Down
3 changes: 3 additions & 0 deletions packages/plugins/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const registerPlugins = (...args: any): void => {
};

const getPlugins = <T extends Plugin = Plugin>(type?: string) => {
if (!type) {
return plugins.all<T>();
}
return plugins.byType<T>(type);
};

Expand Down

0 comments on commit 2291eab

Please sign in to comment.