From ba81c6c0c885896679edb5e56b342d448ca0c3d3 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 7 Feb 2017 14:47:07 -0800 Subject: [PATCH] disable fs watcher for UNC paths on Windows (#13937) --- src/compiler/sys.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index a1e82a66595..7c74de28a6e 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -479,7 +479,10 @@ namespace ts { // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) let options: any; - if (!directoryExists(directoryName)) { + if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { + // do nothing if either + // - target folder does not exist + // - this is UNC path on Windows (https://github.com/Microsoft/TypeScript/issues/13874) return noOpFileWatcher; } @@ -503,6 +506,10 @@ namespace ts { }; } ); + + function isUNCPath(s: string): boolean { + return s.length > 2 && s.charCodeAt(0) === CharacterCodes.slash && s.charCodeAt(1) === CharacterCodes.slash; + } }, resolvePath: function(path: string): string { return _path.resolve(path);