Skip to content

Commit

Permalink
non tty errors
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfiorette committed May 23, 2024
1 parent a3c7119 commit c8278b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Error/BaseError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export type PartialDiagnostic = Omit<ts.Diagnostic, "category" | "file" | "start
category?: ts.DiagnosticCategory;
};

const isTTY = process.env.TTY || process.stdout.isTTY;

/**
* Base error for ts-json-schema-generator
*/
Expand Down Expand Up @@ -49,7 +51,9 @@ export abstract class TJSGError extends Error {
}

format() {
return ts.formatDiagnosticsWithColorAndContext([this.diagnostic], {
const formatter = isTTY ? ts.formatDiagnosticsWithColorAndContext : ts.formatDiagnostics;

return formatter([this.diagnostic], {
getCanonicalFileName: (fileName) => fileName,
getCurrentDirectory: () => "",
getNewLine: () => "\n",
Expand Down

0 comments on commit c8278b9

Please sign in to comment.