Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3ccab96

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 3ccab96

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

‎src/index.ts‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,23 @@ 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 (e instanceof Error && e.message.includes("An error occurred while trying to read the map file at")) {
37+
this.emitWarning(e);
38+
} else {
39+
throw e;
3140
}
3241
}
3342

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /