@@ -49,37 +49,17 @@ class FriendlyErrorsWebpackPlugin {
49
49
const hasWarnings = stats . hasWarnings ( ) ;
50
50
51
51
if ( ! hasErrors && ! hasWarnings ) {
52
- const time = stats . endTime - stats . startTime ;
53
- debug . log ( chalk . green ( 'Compiled successfully in ' + time + 'ms' ) ) ;
54
-
55
- if ( this . compilationSuccessMessage ) {
56
- debug . log ( this . compilationSuccessMessage ) ;
57
- }
58
-
59
- } else if ( hasErrors ) {
60
-
61
- const { errors } = stats . compilation ;
62
- const processedErrors = transformErrors ( errors , transformers ) ;
63
- const nbErrors = processedErrors . length ;
64
- displayCompilationMessage ( `Failed to compile with ${ nbErrors } errors` , 'red' ) ;
65
-
66
- if ( this . notifier ) {
67
- this . notify ( 'Error' , processedErrors [ 0 ] ) ;
68
- }
69
-
70
- const topErrors = getMaxSeverityErrors ( processedErrors ) ;
71
- formatErrors ( topErrors , formatters , 'Error' )
72
- . forEach ( ( chunk ) => debug . log ( chunk ) ) ;
73
-
74
- } else if ( hasWarnings ) {
52
+ this . displaySuccess ( stats ) ;
53
+ return ;
54
+ }
75
55
76
- const { warnings } = stats . compilation ;
77
- const processedWarns = transformErrors ( warnings , transformers ) ;
78
- const nbWarning = processedWarns . length ;
79
- displayCompilationMessage ( `Compiled with ${ nbWarning } warnings` , 'yellow' ) ;
56
+ if ( hasErrors ) {
57
+ this . displayErrors ( stats . compilation . errors , 'red' , this . notifier ) ;
58
+ return ;
59
+ }
80
60
81
- formatErrors ( processedWarns , formatters , 'Warning' )
82
- . forEach ( ( chunk ) => debug . log ( chunk ) ) ;
61
+ if ( hasWarnings ) {
62
+ this . displayErrors ( stats . compilation . warnings , 'yellow' ) ;
83
63
}
84
64
} ) ;
85
65
@@ -88,6 +68,30 @@ class FriendlyErrorsWebpackPlugin {
88
68
debug . log ( chalk . cyan ( 'Compiling...' ) ) ;
89
69
} ) ;
90
70
}
71
+
72
+ displaySuccess ( stats ) {
73
+ const time = stats . endTime - stats . startTime ;
74
+ debug . log ( chalk . green ( 'Compiled successfully in ' + time + 'ms' ) ) ;
75
+
76
+ if ( this . compilationSuccessMessage ) {
77
+ debug . log ( this . compilationSuccessMessage ) ;
78
+ }
79
+ }
80
+
81
+ displayErrors ( errors , color , notifier ) {
82
+
83
+ const processedErrors = transformErrors ( errors , transformers ) ;
84
+ const nbErrors = processedErrors . length ;
85
+ displayCompilationMessage ( `Failed to compile with ${ nbErrors } errors` , color ) ;
86
+
87
+ if ( notifier ) {
88
+ this . notify ( 'Error' , processedErrors [ 0 ] ) ;
89
+ }
90
+
91
+ const topErrors = getMaxSeverityErrors ( processedErrors ) ;
92
+ formatErrors ( topErrors , formatters , 'Error' )
93
+ . forEach ( ( chunk ) => debug . log ( chunk ) ) ;
94
+ }
91
95
}
92
96
93
97
function getMaxSeverityErrors ( errors ) {
0 commit comments