mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
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:
parent
4652fc491f
commit
6d200bffbd
@ -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];
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user