-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--pretty-er output by default #23408
Changes from 3 commits
bd3e854
7fd1dda
299002d
6953fa1
320cb40
25bb581
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,6 +428,7 @@ namespace ts { | |
newLine: string; | ||
useCaseSensitiveFileNames: boolean; | ||
write(s: string): void; | ||
writeOutputIsTty?(): boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a reasonable name @weswigham? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So now there are two CLI flags that can tell tsc it's pretty. What if the user provides |
||
if ((typeof options.pretty === "undefined" && typeof options.diagnosticStyle === "undefined") || options.diagnosticStyle === DiagnosticStyle.Auto) { | ||
return !!sys.writeOutputIsTty && sys.writeOutputIsTty(); | ||
} | ||
return options.diagnosticStyle === DiagnosticStyle.Pretty || options.pretty; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
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) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather we do not add a new flag if we can. i think
auto
is justpretty === undefined
.if we really need a new value i would make pretty take
boolean | "auto"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boolean | "auto" | "simple" | "styled"
? (Where boolean toggles betweenauto
andstyled
).