22
33const friendlySyntaxErrorLabel = "Syntax error:" ;
44
5- function isLikelyASyntaxError ( message ) {
5+ function _isLikelyASyntaxError ( message ) {
66 return message . indexOf ( friendlySyntaxErrorLabel ) !== - 1 ;
77}
88
9- function formatMessage ( message ) {
9+ function _formatMessage ( message ) {
1010 return message
11- . replace (
12- "Module build failed: SyntaxError:" ,
13- friendlySyntaxErrorLabel
14- )
15- . replace (
16- / M o d u l e n o t f o u n d : E r r o r : C a n n o t r e s o l v e ' f i l e ' o r ' d i r e c t o r y ' / ,
17- "Module not found:"
18- )
11+ . replace ( "Module build failed: SyntaxError:" , friendlySyntaxErrorLabel )
12+ . replace ( / M o d u l e n o t f o u n d : E r r o r : C a n n o t r e s o l v e ' f i l e ' o r ' d i r e c t o r y ' / , "Module not found:" )
1913 . replace ( / ^ \s * a t \s .* : \d + : \d + [ \s \) ] * \n / gm, "" )
2014 . replace ( "./~/css-loader!./~/postcss-loader!" , "" ) ;
2115}
2216
23- function lineJoin ( arr ) {
17+ function _lineJoin ( arr ) {
2418 return arr . join ( "\n" ) ;
2519}
2620
@@ -31,20 +25,20 @@ function formatOutput(stats) {
3125 const hasWarnings = stats . hasWarnings ( ) ;
3226
3327 const json = stats . toJson ( ) ;
34- let formattedErrors = json . errors . map ( message => `Error in ${ formatMessage ( message ) } ` ) ;
35- const formattedWarnings = json . warnings . map ( message => `Warning in ${ formatMessage ( message ) } ` ) ;
28+ let formattedErrors = json . errors . map ( message => `Error in ${ _formatMessage ( message ) } ` ) ;
29+ const formattedWarnings = json . warnings . map ( message => `Warning in ${ _formatMessage ( message ) } ` ) ;
3630
3731 if ( hasErrors ) {
3832 output . push ( "{red-fg}Failed to compile.{/}" ) ;
3933 output . push ( "" ) ;
40- if ( formattedErrors . some ( isLikelyASyntaxError ) ) {
41- formattedErrors = formattedErrors . filter ( isLikelyASyntaxError ) ;
34+ if ( formattedErrors . some ( _isLikelyASyntaxError ) ) {
35+ formattedErrors = formattedErrors . filter ( _isLikelyASyntaxError ) ;
4236 }
4337 formattedErrors . forEach ( message => {
4438 output . push ( message ) ;
4539 output . push ( "" ) ;
4640 } ) ;
47- return lineJoin ( output ) ;
41+ return _lineJoin ( output ) ;
4842 }
4943
5044 if ( hasWarnings ) {
@@ -55,13 +49,16 @@ function formatOutput(stats) {
5549 output . push ( "" ) ;
5650 } ) ;
5751
58- return lineJoin ( output ) ;
52+ return _lineJoin ( output ) ;
5953 }
6054
6155 output . push ( "{green-fg}Compiled successfully!{/}" ) ;
6256 output . push ( "" ) ;
6357
64- return lineJoin ( output ) ;
58+ return _lineJoin ( output ) ;
6559}
6660
67- module . exports = formatOutput ;
61+ module . exports = { formatOutput,
62+ _formatMessage,
63+ _isLikelyASyntaxError,
64+ _lineJoin } ;
0 commit comments