Skip to content

Commit 75a4f9c

Browse files
committed
Supresses the IO Exception of convert-source-map
The IO Exception occurs when in the webpack pipeline some files have the .map counterpart but some dont. If the user enables the stats of webpack, he/she would still see the warnings.
1 parent 8dc129e commit 75a4f9c

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/index.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@ export default function(this: loader.LoaderContext, source: string, sourceMap?:
2020
options = Object.assign(defaultOptions, options);
2121
validateOptions(optionsSchema, options, "Coverage Istanbul Loader");
2222

23-
if (!sourceMap) {
24-
// Check for an inline source map
25-
const inlineSourceMap = convert.fromSource(source)
26-
|| convert.fromMapFileSource(source, path.dirname(this.resourcePath));
23+
try {
24+
if (!sourceMap) {
25+
// Check for an inline source map
26+
const inlineSourceMap = convert.fromSource(source)
27+
|| convert.fromMapFileSource(source, path.dirname(this.resourcePath));
2728

28-
if (inlineSourceMap) {
29-
// Use the inline source map
30-
sourceMap = inlineSourceMap.sourcemap as RawSourceMap;
29+
if (inlineSourceMap) {
30+
// Use the inline source map
31+
sourceMap = inlineSourceMap.sourcemap as RawSourceMap;
32+
}
33+
}
34+
} catch (e) {
35+
// Exception is thrown by fromMapFileSource when there is no source map file
36+
if (typeof e === "string" || e instanceof Error) {
37+
this.emitWarning(e);
3138
}
3239
}
3340

0 commit comments

Comments
 (0)