Skip to content

Commit 7960090

Browse files
committed
Add preserveWatchOutput option to build option and report starting compilation and file changes detected status
1 parent dedb2ae commit 7960090

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
@@ -54,6 +54,7 @@ namespace ts {
5454
/*@internal*/ clean?: boolean;
5555
/*@internal*/ watch?: boolean;
5656
/*@internal*/ help?: boolean;
57+
preserveWatchOutput?: boolean;
5758
}
5859

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

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

502509
function invalidateProjectAndScheduleBuilds(resolved: ResolvedConfigFileName) {
510+
reportWatchStatus(Diagnostics.File_change_detected_Starting_incremental_compilation);
503511
invalidateProject(resolved);
504512
if (!hostWithWatch.setTimeout) {
505513
return;
@@ -1038,6 +1046,7 @@ namespace ts {
10381046
}
10391047

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

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)