Use watch invoked with node_modules/.staging as watch for refreshing complete node_modules, so that npm install is reflected correctly (#36039)

* Add test that demonstrates npm install watch behaviour some times

* Use watch invoked with `node_modules/.staging` as watch for refreshing complete node_modules, so that npm install is reflected correctly
Fixes #35966
This commit is contained in:
Sheetal Nandi
2020-01-10 14:58:01 -08:00
committed by GitHub
parent 0c3019e3b3
commit 76ee0214f9
5 changed files with 142 additions and 16 deletions
+5 -4
View File
@@ -1104,7 +1104,7 @@ namespace ts.server {
this.host,
directory,
fileOrDirectory => {
const fileOrDirectoryPath = this.toPath(fileOrDirectory);
let fileOrDirectoryPath: Path | undefined = this.toPath(fileOrDirectory);
const fsResult = project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
// don't trigger callback on open, existing files
@@ -1115,7 +1115,8 @@ namespace ts.server {
return;
}
if (isPathIgnored(fileOrDirectoryPath)) return;
fileOrDirectoryPath = removeIgnoredPath(fileOrDirectoryPath);
if (!fileOrDirectoryPath) return;
const configFilename = project.getConfigFilePath();
if (getBaseFileName(fileOrDirectoryPath) === "package.json" && !isInsideNodeModules(fileOrDirectoryPath) &&
@@ -2272,8 +2273,8 @@ namespace ts.server {
this.host,
watchDir,
(fileOrDirectory) => {
const fileOrDirectoryPath = this.toPath(fileOrDirectory);
if (isPathIgnored(fileOrDirectoryPath)) return;
const fileOrDirectoryPath = removeIgnoredPath(this.toPath(fileOrDirectory));
if (!fileOrDirectoryPath) return;
// Has extension
Debug.assert(result.refCount > 0);