Skip to content

Commit 915ffab

Browse files
authored
disable fs watcher for UNC paths on Windows (microsoft#13937)
1 parent 363d914 commit 915ffab

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/compiler/sys.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,10 @@ namespace ts {
485485
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
486486
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
487487
let options: any;
488-
if (!directoryExists(directoryName)) {
488+
if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) {
489+
// do nothing if either
490+
// - target folder does not exist
491+
// - this is UNC path on Windows (https://github.com/Microsoft/TypeScript/issues/13874)
489492
return noOpFileWatcher;
490493
}
491494

@@ -509,6 +512,10 @@ namespace ts {
509512
};
510513
}
511514
);
515+
516+
function isUNCPath(s: string): boolean {
517+
return s.length > 2 && s.charCodeAt(0) === CharacterCodes.slash && s.charCodeAt(1) === CharacterCodes.slash;
518+
}
512519
},
513520
resolvePath: function(path: string): string {
514521
return _path.resolve(path);

0 commit comments

Comments
 (0)