Merge pull request #23408 from Microsoft/autoPretty

--pretty-er output by default
This commit is contained in:
Daniel Rosenwasser 2018-04-18 23:10:02 -07:00 committed by GitHub
commit 6ee4989674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 9 deletions

View File

@ -428,6 +428,7 @@ namespace ts {
newLine: string;
useCaseSensitiveFileNames: boolean;
write(s: string): void;
writeOutputIsTTY?(): boolean;
readFile(path: string, encoding?: string): string | undefined;
getFileSize?(path: string): number;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
@ -561,6 +562,9 @@ namespace ts {
write(s: string): void {
process.stdout.write(s);
},
writeOutputIsTTY() {
return process.stdout.isTTY;
},
readFile,
writeFile,
watchFile: getWatchFile(),

View File

@ -19,11 +19,18 @@ namespace ts {
let reportDiagnostic = createDiagnosticReporter(sys);
function updateReportDiagnostic(options: CompilerOptions) {
if (options.pretty) {
if (shouldBePretty(options)) {
reportDiagnostic = createDiagnosticReporter(sys, /*pretty*/ true);
}
}
function shouldBePretty(options: CompilerOptions) {
if (typeof options.pretty === "undefined") {
return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY();
}
return options.pretty;
}
function padLeft(s: string, length: number) {
while (s.length < length) {
s = " " + s;
@ -159,7 +166,7 @@ namespace ts {
}
function createWatchStatusReporter(options: CompilerOptions) {
return ts.createWatchStatusReporter(sys, !!options.pretty);
return ts.createWatchStatusReporter(sys, shouldBePretty(options));
}
function createWatchOfConfigFile(configParseResult: ParsedCommandLine, optionsToExtend: CompilerOptions) {

View File

@ -4195,7 +4195,7 @@ namespace ts {
preserveSymlinks?: boolean;
/* @internal */ preserveWatchOutput?: boolean;
project?: string;
/* @internal */ pretty?: DiagnosticStyle;
/* @internal */ pretty?: boolean;
reactNamespace?: string;
jsxFactory?: string;
removeComments?: boolean;
@ -4293,12 +4293,6 @@ namespace ts {
JSX,
}
/* @internal */
export const enum DiagnosticStyle {
Simple,
Pretty,
}
/** Either a parsed command line or a parsed tsconfig.json */
export interface ParsedCommandLine {
options: CompilerOptions;

View File

@ -2889,6 +2889,7 @@ declare namespace ts {
newLine: string;
useCaseSensitiveFileNames: boolean;
write(s: string): void;
writeOutputIsTTY?(): boolean;
readFile(path: string, encoding?: string): string | undefined;
getFileSize?(path: string): number;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;

View File

@ -2889,6 +2889,7 @@ declare namespace ts {
newLine: string;
useCaseSensitiveFileNames: boolean;
write(s: string): void;
writeOutputIsTTY?(): boolean;
readFile(path: string, encoding?: string): string | undefined;
getFileSize?(path: string): number;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;