File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import logger, {
21
21
import PluginOptions from './public/PluginOptions' ;
22
22
import BundleGraph from './BundleGraph' ;
23
23
import { tracer , PluginTracer } from '@parcel/profiler' ;
24
+ import { anyToDiagnostic } from '@parcel/diagnostic' ;
24
25
25
26
type Opts = { |
26
27
options : ParcelOptions ,
@@ -85,7 +86,16 @@ export default class ReporterRunner {
85
86
this . report ( event ) ;
86
87
} ;
87
88
88
- async report ( event : ReporterEvent ) {
89
+ async report ( unsanitisedEvent : ReporterEvent ) {
90
+ let event : ReporterEvent = unsanitisedEvent ;
91
+ if ( event . diagnostics ) {
92
+ // Sanitise input before passing to reporters
93
+ // $FlowFixMe too complex to narrow down by type
94
+ event = {
95
+ ...event ,
96
+ diagnostics : anyToDiagnostic ( event . diagnostics ) ,
97
+ } ;
98
+ }
89
99
for ( let reporter of this . reporters ) {
90
100
let measurement ;
91
101
try {
@@ -95,6 +105,7 @@ export default class ReporterRunner {
95
105
measurement = tracer . createMeasurement ( reporter . name , 'reporter' ) ;
96
106
}
97
107
await reporter . plugin . report ( {
108
+ // $FlowFixMe
98
109
event,
99
110
options : this . pluginOptions ,
100
111
logger : new PluginLogger ( { origin : reporter . name } ) ,
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ export type Diagnostifiable =
114
114
/** Normalize the given value into a diagnostic. */
115
115
export function anyToDiagnostic ( input : Diagnostifiable ) : Array < Diagnostic > {
116
116
if ( Array . isArray ( input ) ) {
117
- return input ;
117
+ return input . flatMap ( e => anyToDiagnostic ( e ) ) ;
118
118
} else if (input instanceof ThrowableDiagnostic) {
119
119
return input . diagnostics ;
120
120
} else if (input instanceof Error) {
You can’t perform that action at this time.
0 commit comments