File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,6 +53,13 @@ class Stats {
5353 } ) ;
5454 }
5555
56+ formatFilePath ( filePath ) {
57+ const OPTIONS_REGEXP = / ^ ( \s | \S ) * ! / ;
58+ return filePath . includes ( "!" )
59+ ? `${ filePath . replace ( OPTIONS_REGEXP , "" ) } (${ filePath } )\n`
60+ : `${ filePath } \n` ;
61+ }
62+
5663 hasWarnings ( ) {
5764 return (
5865 this . compilation . warnings . length > 0 ||
@@ -266,7 +273,9 @@ class Stats {
266273 e . module . readableIdentifier &&
267274 typeof e . module . readableIdentifier === "function"
268275 ) {
269- text += `${ e . module . readableIdentifier ( requestShortener ) } \n` ;
276+ text += this . formatFilePath (
277+ e . module . readableIdentifier ( requestShortener )
278+ ) ;
270279 }
271280 text += e . message ;
272281 if ( showErrorDetails && e . details ) text += `\n${ e . details } ` ;
Original file line number Diff line number Diff line change @@ -9,6 +9,24 @@ const packageJson = require("../package.json");
99describe (
1010 "Stats" ,
1111 ( ) => {
12+ describe ( "formatFilePath" , ( ) => {
13+ it ( "emit the file path and request" , ( ) => {
14+ const mockStats = new Stats ( {
15+ children : [ ] ,
16+ errors : [ "firstError" ] ,
17+ hash : "1234" ,
18+ compiler : {
19+ context : ""
20+ }
21+ } ) ;
22+ const inputPath =
23+ "./node_modules/ts-loader!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/app.vue" ;
24+ const expectPath = `./src/app.vue (${ inputPath } )\n` ;
25+
26+ mockStats . formatFilePath ( inputPath ) . should . be . exactly ( expectPath ) ;
27+ } ) ;
28+ } ) ;
29+
1230 describe ( "Error Handling" , ( ) => {
1331 describe ( "does have" , ( ) => {
1432 it ( "hasErrors" , ( ) => {
You can’t perform that action at this time.
0 commit comments