mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
Respect NO_COLOR in TypeScript output (#1736)
This commit is contained in:
parent
fe8c5d358b
commit
1e837f3281
3 changed files with 9 additions and 4 deletions
|
@ -68,6 +68,7 @@ interface Ts {
|
||||||
createLanguageService: typeof ts.createLanguageService;
|
createLanguageService: typeof ts.createLanguageService;
|
||||||
/* tslint:disable-next-line:max-line-length */
|
/* tslint:disable-next-line:max-line-length */
|
||||||
formatDiagnosticsWithColorAndContext: typeof ts.formatDiagnosticsWithColorAndContext;
|
formatDiagnosticsWithColorAndContext: typeof ts.formatDiagnosticsWithColorAndContext;
|
||||||
|
formatDiagnostics: typeof ts.formatDiagnostics;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A simple object structure for caching resolved modules and their contents.
|
/** A simple object structure for caching resolved modules and their contents.
|
||||||
|
@ -344,10 +345,10 @@ class Compiler implements ts.LanguageServiceHost, ts.FormatDiagnosticsHost {
|
||||||
...service.getSemanticDiagnostics(fileName)
|
...service.getSemanticDiagnostics(fileName)
|
||||||
];
|
];
|
||||||
if (diagnostics.length > 0) {
|
if (diagnostics.length > 0) {
|
||||||
const errMsg = this._ts.formatDiagnosticsWithColorAndContext(
|
const errMsg = os.noColor
|
||||||
diagnostics,
|
? this._ts.formatDiagnostics(diagnostics, this)
|
||||||
this
|
: this._ts.formatDiagnosticsWithColorAndContext(diagnostics, this);
|
||||||
);
|
|
||||||
console.log(errMsg);
|
console.log(errMsg);
|
||||||
// All TypeScript errors are terminal for deno
|
// All TypeScript errors are terminal for deno
|
||||||
this._os.exit(1);
|
this._os.exit(1);
|
||||||
|
|
|
@ -308,6 +308,9 @@ const tsMock = {
|
||||||
createLanguageService() {
|
createLanguageService() {
|
||||||
return {} as any;
|
return {} as any;
|
||||||
},
|
},
|
||||||
|
formatDiagnostics(diagnostics: ReadonlyArray<any>, _host: any): string {
|
||||||
|
return JSON.stringify(diagnostics.map(({ messageText }) => messageText));
|
||||||
|
},
|
||||||
formatDiagnosticsWithColorAndContext(
|
formatDiagnosticsWithColorAndContext(
|
||||||
diagnostics: ReadonlyArray<any>,
|
diagnostics: ReadonlyArray<any>,
|
||||||
_host: any
|
_host: any
|
||||||
|
|
|
@ -264,6 +264,7 @@ export default function makeConfig(commandOptions) {
|
||||||
// bundle
|
// bundle
|
||||||
[typescriptPath]: [
|
[typescriptPath]: [
|
||||||
"createLanguageService",
|
"createLanguageService",
|
||||||
|
"formatDiagnostics",
|
||||||
"formatDiagnosticsWithColorAndContext",
|
"formatDiagnosticsWithColorAndContext",
|
||||||
"ModuleKind",
|
"ModuleKind",
|
||||||
"ScriptKind",
|
"ScriptKind",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue