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.
This commit is contained in:
Andrew Casey 2017-06-21 10:49:17 -07:00
parent 4652fc491f
commit 6d200bffbd
3 changed files with 3 additions and 3 deletions

View File

@ -2028,7 +2028,7 @@ namespace ts.projectSystem {
projectService.openExternalProject({ projectFileName, options: {}, rootFiles: [{ fileName: file1.path, scriptKind: ScriptKind.JS, hasMixedContent: true }] });
checkNumberOfProjects(projectService, { externalProjects: 1 });
checkWatchedFiles(host, []);
checkWatchedFiles(host, [libFile.path]); // watching the "missing" lib file
const project = projectService.externalProjects[0];

View File

@ -731,7 +731,7 @@ namespace ts.projectSystem {
checkNumberOfProjects(projectService, { configuredProjects: 1 });
const p = projectService.configuredProjects[0];
checkProjectActualFiles(p, [app.path, jsconfig.path]);
checkWatchedFiles(host, [jsconfig.path, "/bower_components", "/node_modules"]);
checkWatchedFiles(host, [jsconfig.path, "/bower_components", "/node_modules", libFile.path]);
installer.installAll(/*expectedCount*/ 1);

View File

@ -631,7 +631,7 @@ namespace ts.server {
// Missing files that are not yet watched should be added to the map.
missingFilePaths.forEach(p => {
if (!this.missingFilesMap.contains(p)) {
const fileWatcher = ts.sys.watchFile(p, (_filename: string, removed?: boolean) => {
const fileWatcher = this.projectService.host.watchFile(p, (_filename: string, removed?: boolean) => {
// removed = deleted ? true : (added ? false : undefined)
if (removed === false && this.missingFilesMap.contains(p)) {
fileWatcher.close();