Skip to content

Commit

Permalink
fix: allow to specify pretty errors in TTY (#1420)
Browse files Browse the repository at this point in the history
* fix: allow to specify pretty errors in TTY

closes #1418

* lint fix

Co-authored-by: Andrew Bradley <cspotcode@gmail.com>
  • Loading branch information
elevatebart and cspotcode committed Aug 8, 2021
1 parent 9c1c9ce commit b044e71
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/index.ts
Expand Up @@ -675,10 +675,12 @@ export function create(rawOptions: CreateOptions = {}): Service {
},
});

const formatDiagnostics =
process.stdout.isTTY || options.pretty
? ts.formatDiagnosticsWithColorAndContext || ts.formatDiagnostics
: ts.formatDiagnostics;
const shouldHavePrettyErrors =
options.pretty === undefined ? process.stdout.isTTY : options.pretty;

const formatDiagnostics = shouldHavePrettyErrors
? ts.formatDiagnosticsWithColorAndContext || ts.formatDiagnostics
: ts.formatDiagnostics;

function createTSError(diagnostics: ReadonlyArray<_ts.Diagnostic>) {
const diagnosticText = formatDiagnostics(diagnostics, diagnosticHost);
Expand Down

0 comments on commit b044e71

Please sign in to comment.