File tree 4 files changed +25
-4
lines changed
4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,14 @@ namespace ts {
56
56
category : Diagnostics . Command_line_Options ,
57
57
description : Diagnostics . Stylize_errors_and_messages_using_color_and_context_experimental
58
58
} ,
59
+ {
60
+ name : "diagnosticStyle" ,
61
+ type : createMapFromTemplate ( {
62
+ auto : DiagnosticStyle . Auto ,
63
+ pretty : DiagnosticStyle . Pretty ,
64
+ simple : DiagnosticStyle . Simple ,
65
+ } ) ,
66
+ } ,
59
67
{
60
68
name : "preserveWatchOutput" ,
61
69
type : "boolean" ,
Original file line number Diff line number Diff line change @@ -428,6 +428,7 @@ namespace ts {
428
428
newLine : string ;
429
429
useCaseSensitiveFileNames : boolean ;
430
430
write ( s : string ) : void ;
431
+ writeOutputIsTty ?( ) : boolean ;
431
432
readFile ( path : string , encoding ?: string ) : string | undefined ;
432
433
getFileSize ?( path : string ) : number ;
433
434
writeFile ( path : string , data : string , writeByteOrderMark ?: boolean ) : void ;
@@ -561,6 +562,9 @@ namespace ts {
561
562
write ( s : string ) : void {
562
563
process . stdout . write ( s ) ;
563
564
} ,
565
+ writeOutputIsTty ( ) {
566
+ return process . stdout . isTTY ;
567
+ } ,
564
568
readFile,
565
569
writeFile,
566
570
watchFile : getWatchFile ( ) ,
Original file line number Diff line number Diff line change @@ -19,11 +19,18 @@ namespace ts {
19
19
20
20
let reportDiagnostic = createDiagnosticReporter ( sys ) ;
21
21
function updateReportDiagnostic ( options : CompilerOptions ) {
22
- if ( options . pretty ) {
22
+ if ( shouldBePretty ( options ) ) {
23
23
reportDiagnostic = createDiagnosticReporter ( sys , /*pretty*/ true ) ;
24
24
}
25
25
}
26
26
27
+ function shouldBePretty ( options : CompilerOptions ) {
28
+ if ( ( typeof options . pretty === "undefined" && typeof options . diagnosticStyle === "undefined" ) || options . diagnosticStyle === DiagnosticStyle . Auto ) {
29
+ return ! ! sys . writeOutputIsTty && sys . writeOutputIsTty ( ) ;
30
+ }
31
+ return options . diagnosticStyle === DiagnosticStyle . Pretty || options . pretty ;
32
+ }
33
+
27
34
function padLeft ( s : string , length : number ) {
28
35
while ( s . length < length ) {
29
36
s = " " + s ;
@@ -159,7 +166,7 @@ namespace ts {
159
166
}
160
167
161
168
function createWatchStatusReporter ( options : CompilerOptions ) {
162
- return ts . createWatchStatusReporter ( sys , ! ! options . pretty ) ;
169
+ return ts . createWatchStatusReporter ( sys , shouldBePretty ( options ) ) ;
163
170
}
164
171
165
172
function createWatchOfConfigFile ( configParseResult : ParsedCommandLine , optionsToExtend : CompilerOptions ) {
Original file line number Diff line number Diff line change @@ -4193,7 +4193,8 @@ namespace ts {
4193
4193
preserveSymlinks ?: boolean ;
4194
4194
/* @internal */ preserveWatchOutput ?: boolean ;
4195
4195
project ?: string ;
4196
- /* @internal */ pretty ?: DiagnosticStyle ;
4196
+ /* @internal */ pretty ?: boolean ;
4197
+ /* @internal */ diagnosticStyle ?: DiagnosticStyle ;
4197
4198
reactNamespace ?: string ;
4198
4199
jsxFactory ?: string ;
4199
4200
removeComments ?: boolean ;
@@ -4293,8 +4294,9 @@ namespace ts {
4293
4294
4294
4295
/* @internal */
4295
4296
export const enum DiagnosticStyle {
4296
- Simple ,
4297
+ Auto ,
4297
4298
Pretty ,
4299
+ Simple ,
4298
4300
}
4299
4301
4300
4302
/** Either a parsed command line or a parsed tsconfig.json */
You can’t perform that action at this time.
0 commit comments