Used return value from clearScreenIfNotWatchingForFiles

This commit is contained in:
Josh Goldberg
2018-04-19 21:53:01 -07:00
parent d1b044b72f
commit 8d6c2bc1b1
+11 -9
View File
@@ -34,14 +34,20 @@ namespace ts {
Diagnostics.Found_0_errors.code
];
function clearScreenIfNotWatchingForFileChanges(system: System, diagnostic: Diagnostic, options: CompilerOptions) {
/**
* @returns Whether the screen was cleared.
*/
function clearScreenIfNotWatchingForFileChanges(system: System, diagnostic: Diagnostic, options: CompilerOptions): boolean {
if (system.clearScreen &&
!options.preserveWatchOutput &&
!options.extendedDiagnostics &&
!options.diagnostics &&
!contains(nonClearingMessageCodes, diagnostic.code)) {
system.clearScreen();
return true;
}
return false;
}
/** @internal */
@@ -50,12 +56,6 @@ namespace ts {
Diagnostics.File_change_detected_Starting_incremental_compilation.code,
];
function getPlainDiagnosticPrecedingNewLines(diagnostic: Diagnostic, newLine: string, preserveWatchOutput?: boolean): string {
return !preserveWatchOutput && contains(screenStartingMessageCodes, diagnostic.code)
? ""
: newLine;
}
function getPlainDiagnosticFollowingNewLines(diagnostic: Diagnostic, newLine: string): string {
return contains(screenStartingMessageCodes, diagnostic.code)
? newLine + newLine
@@ -74,8 +74,10 @@ namespace ts {
system.write(output);
} :
(diagnostic, newLine, options) => {
clearScreenIfNotWatchingForFileChanges(system, diagnostic, options);
let output = `${getPlainDiagnosticPrecedingNewLines(diagnostic, newLine, options.preserveWatchOutput)}${new Date().toLocaleTimeString()} - `;
if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) {
system.write(newLine);
}
let output = `${new Date().toLocaleTimeString()} - `;
output += `${flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)}${getPlainDiagnosticFollowingNewLines(diagnostic, newLine)}`;
system.write(output);
};