Forget about tty detection. It won't work in build tools.

This commit is contained in:
Daniel Rosenwasser 2015-11-02 14:48:28 -08:00
parent 654cbd9779
commit 40f10abe01
2 changed files with 6 additions and 9 deletions

View file

@ -6,7 +6,6 @@ namespace ts {
newLine: string; newLine: string;
useCaseSensitiveFileNames: boolean; useCaseSensitiveFileNames: boolean;
write(s: string): void; write(s: string): void;
writesToTty?(): boolean;
readFile(path: string, encoding?: string): string; readFile(path: string, encoding?: string): string;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher; watchFile?(path: string, callback: (path: string, removed?: boolean) => void): FileWatcher;
@ -379,7 +378,6 @@ namespace ts {
write(s: string): void { write(s: string): void {
process.stdout.write(s); process.stdout.write(s);
}, },
writesToTty: () => _tty.isatty(1),
readFile, readFile,
writeFile, writeFile,
watchFile: (fileName, callback) => { watchFile: (fileName, callback) => {

View file

@ -104,13 +104,12 @@ namespace ts {
sys.write(output); sys.write(output);
} }
const shouldUseColors = !!sys.writesToTty && sys.writesToTty(); const redForegroundEscapeSequence = "\u001b[91m";
const redForegroundEscapeSequence = shouldUseColors ? "\u001b[91m" : ""; const yellowForegroundEscapeSequence = "\u001b[93m";
const yellowForegroundEscapeSequence = shouldUseColors ? "\u001b[93m" : ""; const blueForegroundEscapeSequence = "\u001b[93m";
const blueForegroundEscapeSequence = shouldUseColors ? "\u001b[93m" : ""; const gutterStyleSequence = "\u001b[100;30m";
const gutterStyleSequence = shouldUseColors ? "\u001b[100;30m" : ""; const gutterSeparator = " ";
const gutterSeparator = shouldUseColors ? " " : " | "; const resetEscapeSequence = "\u001b[0m";
const resetEscapeSequence = shouldUseColors ? "\u001b[0m" : "";
const elipsis = "..."; const elipsis = "...";
const categoryFormatMap: Map<string> = { const categoryFormatMap: Map<string> = {
[DiagnosticCategory.Warning]: yellowForegroundEscapeSequence, [DiagnosticCategory.Warning]: yellowForegroundEscapeSequence,