@@ -22,6 +22,8 @@ import {
22
22
printGeneralInfoMessage ,
23
23
printCompileTimeMessages ,
24
24
webpackStatToJsonOptions ,
25
+ printErrorHeading ,
26
+ printWarningHeading ,
25
27
} from './utils' ;
26
28
27
29
/**
@@ -81,22 +83,28 @@ export function serve(options: ProgramOptions | undefined): void {
81
83
done : ( ) => {
82
84
printSuccessfullyCompiledMessage ( ) ;
83
85
} ,
86
+ onWatching ( ) {
87
+ printWatchingMessage ( ) ;
88
+ } ,
84
89
onError : msg => {
85
- console . log ( ' ') ;
86
- console . log ( ` ${ chalk . bgRed . black ( ' ERROR ' ) } please review` ) ;
87
- console . log ( '' ) ;
88
- msg . errors . forEach ( e => console . log ( e ) ) ;
89
- console . log ( '' ) ;
90
+ printErrorHeading ( 'ERROR ') ;
91
+ msg . errors . forEach ( e => {
92
+ console . log ( e ) ;
93
+ console . log ( '' ) ;
94
+ } ) ;
90
95
printFailedCompileMEssage ( ) ;
91
96
} ,
92
97
onWarn : msg => {
98
+ printWarningHeading ( 'WARNING' ) ;
99
+ msg . warnings . forEach ( e => {
100
+ console . log ( e ) ;
101
+ console . log ( '' ) ;
102
+ } ) ;
93
103
printCompiledWithWarnMessage ( ) ;
94
- msg . warnings . forEach ( e => console . log ( e ) ) ;
95
104
} ,
96
105
onEmit : stats => {
97
106
printCompileTimeMessages ( stats , lastWebpackStat ) ;
98
107
lastWebpackStat = stats . toJson ( webpackStatToJsonOptions ) ;
99
- printWatchingMessage ( ) ;
100
108
} ,
101
109
firstCompile : ( stats : webpack . Stats ) => {
102
110
spinner . stop ( ) ;
@@ -107,27 +115,55 @@ export function serve(options: ProgramOptions | undefined): void {
107
115
console . log ( '' ) ;
108
116
109
117
if ( stats . hasErrors ( ) ) {
110
- console . log ( '' ) ;
111
- console . log (
112
- `${ chalk . bgRed . black ( ' ERROR ' ) } please review`
113
- ) ;
114
- messages . errors . forEach ( e => console . log ( e ) ) ;
115
- console . log ( '' ) ;
118
+ printErrorHeading ( 'ERROR' ) ;
119
+ messages . errors . forEach ( e => {
120
+ console . log ( e ) ;
121
+ console . log ( '' ) ;
122
+ } ) ;
116
123
printFailedCompileMEssage ( ) ;
117
124
} else if ( stats . hasWarnings ( ) ) {
125
+ printWarningHeading ( 'WARNING' ) ;
126
+ messages . warnings . forEach ( e => {
127
+ console . log ( e ) ;
128
+ console . log ( '' ) ;
129
+ } ) ;
118
130
printCompiledWithWarnMessage ( ) ;
119
- messages . warnings . forEach ( e => console . log ( e ) ) ;
120
131
} else {
121
132
printSuccessfullyCompiledMessage ( ) ;
122
133
}
123
134
printCompileTimeMessages ( stats , lastWebpackStat ) ;
124
- printWatchingMessage ( ) ;
125
135
lastWebpackStat = stats . toJson ( webpackStatToJsonOptions ) ;
126
136
} ,
127
137
onBsChange ( file ) {
128
138
printGeneralInfoMessage ( `changed: ${ chalk . bold ( file ) } ` ) ;
129
139
printGeneralInfoMessage ( 'reloading browser' ) ;
130
140
} ,
141
+ onTcStart ( ) {
142
+ printGeneralInfoMessage ( 'waiting for typecheck results...' ) ;
143
+ } ,
144
+ onTcEnd ( messages ) {
145
+ if ( messages . errors . length || messages . warnings . length ) {
146
+ if ( messages . errors . length ) {
147
+ printErrorHeading ( 'TS ERROR' ) ;
148
+ messages . errors . forEach ( e => {
149
+ console . log ( e ) ;
150
+ console . log ( '' ) ;
151
+ } ) ;
152
+ }
153
+ if ( messages . warnings . length ) {
154
+ printWarningHeading ( 'TS WARNING' ) ;
155
+ messages . warnings . forEach ( e => {
156
+ console . log ( e ) ;
157
+ console . log ( '' ) ;
158
+ } ) ;
159
+ }
160
+ } else {
161
+ printGeneralInfoMessage (
162
+ 'no typecheck errors' ,
163
+ logSymbols . success
164
+ ) ;
165
+ }
166
+ } ,
131
167
} ) ;
132
168
server . serve ( ) ;
133
169
0 commit comments