Skip to content

Commit 8d7df0a

Browse files
committed
Add preserveWatchOutput option to build option and report starting compilation and file changes detected status
1 parent 4570d97 commit 8d7df0a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/compiler/tsbuild.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace ts {
5353
/*@internal*/ clean?: boolean;
5454
/*@internal*/ watch?: boolean;
5555
/*@internal*/ help?: boolean;
56+
preserveWatchOutput?: boolean;
5657
}
5758

5859
enum BuildResultFlags {
@@ -464,6 +465,12 @@ namespace ts {
464465
host.reportSolutionBuilderStatus(createCompilerDiagnostic(message, ...args));
465466
}
466467

468+
function reportWatchStatus(message: DiagnosticMessage, ...args: string[]) {
469+
if (hostWithWatch.onWatchStatusChange) {
470+
hostWithWatch.onWatchStatusChange(createCompilerDiagnostic(message, ...args), host.getNewLine(), { preserveWatchOutput: context.options.preserveWatchOutput });
471+
}
472+
}
473+
467474
function startWatching() {
468475
const graph = getGlobalDependencyGraph()!;
469476
if (!graph.buildQueue) {
@@ -499,6 +506,7 @@ namespace ts {
499506
}
500507

501508
function invalidateProjectAndScheduleBuilds(resolved: ResolvedConfigFileName) {
509+
reportWatchStatus(Diagnostics.File_change_detected_Starting_incremental_compilation);
502510
invalidateProject(resolved);
503511
if (!hostWithWatch.setTimeout) {
504512
return;
@@ -1037,6 +1045,7 @@ namespace ts {
10371045
}
10381046

10391047
function buildAllProjects(): ExitStatus {
1048+
if (context.options.watch) { reportWatchStatus(Diagnostics.Starting_compilation_in_watch_mode); }
10401049
const graph = getGlobalDependencyGraph();
10411050
if (graph === undefined) return ExitStatus.DiagnosticsPresent_OutputsSkipped;
10421051

src/tsc/tsc.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,13 @@ namespace ts {
211211
category: Diagnostics.Command_line_Options,
212212
description: Diagnostics.Watch_input_files,
213213
type: "boolean"
214-
}
214+
},
215+
{
216+
name: "preserveWatchOutput",
217+
type: "boolean",
218+
category: Diagnostics.Command_line_Options,
219+
description: Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen,
220+
},
215221
];
216222
let buildOptionNameMap: OptionNameMap | undefined;
217223
const returnBuildOptionNameMap = () => (buildOptionNameMap || (buildOptionNameMap = createOptionNameMap(buildOpts)));

0 commit comments

Comments
 (0)