@@ -14,31 +14,18 @@ export class PluginHost extends AbstractComponent<Application> {
14
14
plugins ! : string [ ] ;
15
15
16
16
/**
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.
21
18
* @returns TRUE on success, otherwise FALSE.
22
19
*/
23
20
load ( ) : boolean {
24
21
const logger = this . application . logger ;
25
- const plugins = this . plugins || this . discoverNpmPlugins ( ) ;
22
+ const plugins = this . plugins . length ? this . plugins : this . discoverNpmPlugins ( ) ;
26
23
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 ;
38
26
}
39
27
40
- for ( i = 0 ; i < c ; i ++ ) {
41
- const plugin = plugins [ i ] ;
28
+ for ( const plugin of plugins ) {
42
29
try {
43
30
const instance = require ( plugin ) ;
44
31
const initFunction = typeof instance . load === 'function'
0 commit comments