Skip to content

Commit 6d200bf

Browse files
committed
Watch files through the host
Call `this.projectService.host.watchFile`, rather than `ts.sys.watchFile` so that it gets mocked correctly in the unit tests. Repair two failing tests.
1 parent 4652fc4 commit 6d200bf

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ namespace ts.projectSystem {
20282028
projectService.openExternalProject({ projectFileName, options: {}, rootFiles: [{ fileName: file1.path, scriptKind: ScriptKind.JS, hasMixedContent: true }] });
20292029

20302030
checkNumberOfProjects(projectService, { externalProjects: 1 });
2031-
checkWatchedFiles(host, []);
2031+
checkWatchedFiles(host, [libFile.path]); // watching the "missing" lib file
20322032

20332033
const project = projectService.externalProjects[0];
20342034

src/harness/unittests/typingsInstaller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ namespace ts.projectSystem {
731731
checkNumberOfProjects(projectService, { configuredProjects: 1 });
732732
const p = projectService.configuredProjects[0];
733733
checkProjectActualFiles(p, [app.path, jsconfig.path]);
734-
checkWatchedFiles(host, [jsconfig.path, "/bower_components", "/node_modules"]);
734+
checkWatchedFiles(host, [jsconfig.path, "/bower_components", "/node_modules", libFile.path]);
735735

736736
installer.installAll(/*expectedCount*/ 1);
737737

src/server/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ namespace ts.server {
631631
// Missing files that are not yet watched should be added to the map.
632632
missingFilePaths.forEach(p => {
633633
if (!this.missingFilesMap.contains(p)) {
634-
const fileWatcher = ts.sys.watchFile(p, (_filename: string, removed?: boolean) => {
634+
const fileWatcher = this.projectService.host.watchFile(p, (_filename: string, removed?: boolean) => {
635635
// removed = deleted ? true : (added ? false : undefined)
636636
if (removed === false && this.missingFilesMap.contains(p)) {
637637
fileWatcher.close();

0 commit comments

Comments
 (0)