@@ -93,8 +93,8 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => {
93
93
config . plugins = config . plugins || [ ] ;
94
94
config . reporters = config . reporters || [ ] ;
95
95
const { plugins, reporters} = config ;
96
- const hasCoveragePlugin = plugins . some ( ( p : { } ) => 'reporter:coverage' in p ) ;
97
- const hasIstanbulPlugin = plugins . some ( ( p : { } ) => 'reporter:coverage-istanbul' in p ) ;
96
+ const hasCoveragePlugin = plugins . some ( isPlugin ( 'karma-coverage' , 'reporter:coverage' ) ) ;
97
+ const hasIstanbulPlugin = plugins . some ( isPlugin ( 'karma-coverage-istanbul-reporter' , 'reporter:coverage-istanbul' ) ) ;
98
98
const hasCoverageReporter = reporters . includes ( 'coverage' ) ;
99
99
const hasIstanbulReporter = reporters . includes ( 'coverage-istanbul' ) ;
100
100
if ( hasCoveragePlugin && ! hasCoverageReporter ) {
@@ -334,6 +334,22 @@ function fallbackMiddleware() {
334
334
} ;
335
335
}
336
336
337
+ /**
338
+ * Returns a function that returns true if the plugin identifier matches the
339
+ * `moduleId` or `pluginName`. A plugin identifier can be either a string or
340
+ * an object according to https://karma-runner.github.io/5.2/config/plugins.html
341
+ * @param moduleId name of the node module (e.g. karma-coverage)
342
+ * @param pluginName name of the karma plugin (e.g. reporter:coverage)
343
+ */
344
+ function isPlugin ( moduleId : string , pluginName : string ) {
345
+ return ( plugin : string | { } ) : boolean => {
346
+ if ( typeof plugin === 'string' ) {
347
+ return plugin === moduleId ;
348
+ }
349
+ return pluginName in plugin ;
350
+ }
351
+ }
352
+
337
353
module . exports = {
338
354
'framework:@angular-devkit/build-angular' : [ 'factory' , init ] ,
339
355
'reporter:@angular-devkit/build-angular--sourcemap-reporter' : [ 'type' , sourceMapReporter ] ,
0 commit comments