Skip to content

Commit

Permalink
fix: Autodiscovery of plugins not working
Browse files Browse the repository at this point in the history
Closes #1170
  • Loading branch information
Gerrit0 committed Jan 14, 2020
1 parent 8005b21 commit 9ac6973
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/lib/utils/plugins.ts
Expand Up @@ -14,31 +14,18 @@ export class PluginHost extends AbstractComponent<Application> {
plugins!: string[];

/**
* Load the given list of npm plugins.
*
* @param plugins A list of npm modules that should be loaded as plugins. When not specified
* this function will invoke [[discoverNpmPlugins]] to find a list of all installed plugins.
* Load all npm plugins.
* @returns TRUE on success, otherwise FALSE.
*/
load(): boolean {
const logger = this.application.logger;
const plugins = this.plugins || this.discoverNpmPlugins();
const plugins = this.plugins.length ? this.plugins : this.discoverNpmPlugins();

let i: number, c: number = plugins.length;
for (i = 0; i < c; i++) {
const plugin = plugins[i];
// TSLint would be correct here, but it doesn't take into account user config files.
// tslint:disable-next-line:strict-type-predicates
if (typeof plugin !== 'string') {
logger.error('Unknown plugin %s', plugin);
return false;
} else if (plugin.toLowerCase() === 'none') {
return true;
}
if (plugins.some(plugin => plugin.toLowerCase() === 'none')) {
return true;
}

for (i = 0; i < c; i++) {
const plugin = plugins[i];
for (const plugin of plugins) {
try {
const instance = require(plugin);
const initFunction = typeof instance.load === 'function'
Expand Down

0 comments on commit 9ac6973

Please sign in to comment.