Skip to content

Commit 9ac6973

Browse files
committed
fix: Autodiscovery of plugins not working
Closes TypeStrong#1170
1 parent 8005b21 commit 9ac6973

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/lib/utils/plugins.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,18 @@ export class PluginHost extends AbstractComponent<Application> {
1414
plugins!: string[];
1515

1616
/**
17-
* Load the given list of npm plugins.
18-
*
19-
* @param plugins A list of npm modules that should be loaded as plugins. When not specified
20-
* this function will invoke [[discoverNpmPlugins]] to find a list of all installed plugins.
17+
* Load all npm plugins.
2118
* @returns TRUE on success, otherwise FALSE.
2219
*/
2320
load(): boolean {
2421
const logger = this.application.logger;
25-
const plugins = this.plugins || this.discoverNpmPlugins();
22+
const plugins = this.plugins.length ? this.plugins : this.discoverNpmPlugins();
2623

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

40-
for (i = 0; i < c; i++) {
41-
const plugin = plugins[i];
28+
for (const plugin of plugins) {
4229
try {
4330
const instance = require(plugin);
4431
const initFunction = typeof instance.load === 'function'

0 commit comments

Comments
 (0)