@@ -44,6 +44,24 @@ namespace ts {
44
44
}
45
45
}
46
46
47
+ /** @internal */
48
+ const screenStartingMessageCodes : number [ ] = [
49
+ Diagnostics . Starting_compilation_in_watch_mode . code ,
50
+ Diagnostics . File_change_detected_Starting_incremental_compilation . code ,
51
+ ] ;
52
+
53
+ function getPlainDiagnosticPrecedingNewLines ( diagnostic : Diagnostic , newLine : string ) : string {
54
+ return contains ( screenStartingMessageCodes , diagnostic . code )
55
+ ? ""
56
+ : newLine ;
57
+ }
58
+
59
+ function getPlainDiagnosticFollowingNewLines ( diagnostic : Diagnostic , newLine : string ) : string {
60
+ return contains ( screenStartingMessageCodes , diagnostic . code )
61
+ ? newLine + newLine
62
+ : newLine ;
63
+ }
64
+
47
65
/**
48
66
* Create a function that reports watch status by writing to the system and handles the formating of the diagnostic
49
67
*/
@@ -52,13 +70,13 @@ namespace ts {
52
70
( diagnostic , newLine , options ) => {
53
71
clearScreenIfNotWatchingForFileChanges ( system , diagnostic , options ) ;
54
72
let output = `[${ formatColorAndReset ( new Date ( ) . toLocaleTimeString ( ) , ForegroundColorEscapeSequences . Grey ) } ] ` ;
55
- output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ newLine + newLine + newLine } ` ;
73
+ output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ newLine + newLine } ` ;
56
74
system . write ( output ) ;
57
75
} :
58
76
( diagnostic , newLine , options ) => {
59
77
clearScreenIfNotWatchingForFileChanges ( system , diagnostic , options ) ;
60
- let output = new Date ( ) . toLocaleTimeString ( ) + " - " ;
61
- output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ newLine + newLine + newLine } ` ;
78
+ let output = ` ${ getPlainDiagnosticPrecedingNewLines ( diagnostic , newLine ) } ${ new Date ( ) . toLocaleTimeString ( ) } - ` ;
79
+ output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ getPlainDiagnosticFollowingNewLines ( diagnostic , newLine ) } ` ;
62
80
system . write ( output ) ;
63
81
} ;
64
82
}
0 commit comments