@@ -177,8 +177,9 @@ func main() {
177
177
var bindTime , checkTime time.Duration
178
178
179
179
diagnostics := program .GetOptionsDiagnostics ()
180
+ formatOpts := getFormatOpts (host )
180
181
if len (diagnostics ) != 0 {
181
- printDiagnostics (diagnostics , host , compilerOptions )
182
+ printDiagnostics (diagnostics , formatOpts , compilerOptions )
182
183
os .Exit (1 )
183
184
}
184
185
@@ -216,7 +217,7 @@ func main() {
216
217
runtime .ReadMemStats (& memStats )
217
218
218
219
if ! opts .devel .quiet && len (diagnostics ) != 0 {
219
- printDiagnostics (diagnostics , host , compilerOptions )
220
+ printDiagnostics (diagnostics , formatOpts , compilerOptions )
220
221
}
221
222
222
223
if compilerOptions .ListFiles .IsTrue () {
@@ -290,22 +291,24 @@ func listFiles(p *ts.Program) {
290
291
}
291
292
}
292
293
293
- func printDiagnostics (diagnostics []* ast.Diagnostic , host ts.CompilerHost , compilerOptions * core.CompilerOptions ) {
294
- comparePathOptions := tspath.ComparePathsOptions {
295
- CurrentDirectory : host .GetCurrentDirectory (),
296
- UseCaseSensitiveFileNames : host .FS ().UseCaseSensitiveFileNames (),
294
+ func getFormatOpts (host ts.CompilerHost ) * diagnosticwriter.FormattingOptions {
295
+ return & diagnosticwriter.FormattingOptions {
296
+ NewLine : host .NewLine (),
297
+ ComparePathsOptions : tspath.ComparePathsOptions {
298
+ CurrentDirectory : host .GetCurrentDirectory (),
299
+ UseCaseSensitiveFileNames : host .FS ().UseCaseSensitiveFileNames (),
300
+ },
297
301
}
302
+ }
303
+
304
+ func printDiagnostics (diagnostics []* ast.Diagnostic , formatOpts * diagnosticwriter.FormattingOptions , compilerOptions * core.CompilerOptions ) {
298
305
if compilerOptions .Pretty .IsTrueOrUnknown () {
299
- formatOpts := diagnosticwriter.FormattingOptions {
300
- NewLine : "\n " ,
301
- ComparePathsOptions : comparePathOptions ,
302
- }
303
- diagnosticwriter .FormatDiagnosticsWithColorAndContext (os .Stdout , diagnostics , & formatOpts )
306
+ diagnosticwriter .FormatDiagnosticsWithColorAndContext (os .Stdout , diagnostics , formatOpts )
304
307
fmt .Fprintln (os .Stdout )
305
- diagnosticwriter .WriteErrorSummaryText (os .Stdout , diagnostics , & formatOpts )
308
+ diagnosticwriter .WriteErrorSummaryText (os .Stdout , diagnostics , formatOpts )
306
309
} else {
307
310
for _ , diagnostic := range diagnostics {
308
- printDiagnostic (diagnostic , 0 , comparePathOptions )
311
+ printDiagnostic (diagnostic , 0 , formatOpts . ComparePathsOptions )
309
312
}
310
313
}
311
314
}
0 commit comments