Skip to content

Commit

Permalink
Update LKG
Browse files Browse the repository at this point in the history
  • Loading branch information
mhegazy committed Feb 16, 2017
1 parent 08fe20e commit 510b384
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 54 deletions.
27 changes: 19 additions & 8 deletions lib/tsc.js
Expand Up @@ -2025,6 +2025,21 @@ var ts;
})(ts || (ts = {}));
var ts;
(function (ts) {
function getNodeMajorVersion() {
if (typeof process === "undefined") {
return undefined;
}
var version = process.version;
if (!version) {
return undefined;
}
var dot = version.indexOf(".");
if (dot === -1) {
return undefined;
}
return parseInt(version.substring(1, dot));
}
ts.getNodeMajorVersion = getNodeMajorVersion;
ts.sys = (function () {
function getWScriptSystem() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
Expand Down Expand Up @@ -2215,9 +2230,8 @@ var ts;
}
}
var watchedFileSet = createWatchedFileSet();
function isNode4OrLater() {
return parseInt(process.version.charAt(1)) >= 4;
}
var nodeVersion = getNodeMajorVersion();
var isNode4OrLater = nodeVersion >= 4;
function isFileSystemCaseSensitive() {
if (platform === "win32" || platform === "win64") {
return false;
Expand Down Expand Up @@ -2351,10 +2365,10 @@ var ts;
},
watchDirectory: function (directoryName, callback, recursive) {
var options;
if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) {
if (!directoryExists(directoryName)) {
return noOpFileWatcher;
}
if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) {
if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) {
options = { persistent: true, recursive: !!recursive };
}
else {
Expand All @@ -2366,9 +2380,6 @@ var ts;
}
;
});
function isUNCPath(s) {
return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47;
}
},
resolvePath: function (path) {
return _path.resolve(path);
Expand Down
92 changes: 84 additions & 8 deletions lib/tsserver.js
Expand Up @@ -2981,6 +2981,21 @@ var ts;
})(ts || (ts = {}));
var ts;
(function (ts) {
function getNodeMajorVersion() {
if (typeof process === "undefined") {
return undefined;
}
var version = process.version;
if (!version) {
return undefined;
}
var dot = version.indexOf(".");
if (dot === -1) {
return undefined;
}
return parseInt(version.substring(1, dot));
}
ts.getNodeMajorVersion = getNodeMajorVersion;
ts.sys = (function () {
function getWScriptSystem() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
Expand Down Expand Up @@ -3171,9 +3186,8 @@ var ts;
}
}
var watchedFileSet = createWatchedFileSet();
function isNode4OrLater() {
return parseInt(process.version.charAt(1)) >= 4;
}
var nodeVersion = getNodeMajorVersion();
var isNode4OrLater = nodeVersion >= 4;
function isFileSystemCaseSensitive() {
if (platform === "win32" || platform === "win64") {
return false;
Expand Down Expand Up @@ -3312,10 +3326,10 @@ var ts;
},
watchDirectory: function (directoryName, callback, recursive) {
var options;
if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) {
if (!directoryExists(directoryName)) {
return noOpFileWatcher;
}
if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) {
if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) {
options = { persistent: true, recursive: !!recursive };
}
else {
Expand All @@ -3327,9 +3341,6 @@ var ts;
}
;
});
function isUNCPath(s) {
return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47;
}
},
resolvePath: function (path) {
return _path.resolve(path);
Expand Down Expand Up @@ -74540,7 +74551,72 @@ var ts;
writeMessage(pending.shift());
}
}
function extractWatchDirectoryCacheKey(path, currentDriveKey) {
path = ts.normalizeSlashes(path);
if (isUNCPath(path)) {
var firstSlash = path.indexOf(ts.directorySeparator, 2);
return firstSlash !== -1 ? path.substring(0, firstSlash).toLowerCase() : path;
}
var rootLength = ts.getRootLength(path);
if (rootLength === 0) {
return currentDriveKey;
}
if (path.charCodeAt(1) === 58 && path.charCodeAt(2) === 47) {
return path.charAt(0).toLowerCase();
}
if (path.charCodeAt(0) === 47 && path.charCodeAt(1) !== 47) {
return currentDriveKey;
}
return undefined;
}
function isUNCPath(s) {
return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47;
}
var sys = ts.sys;
var useWatchGuard = process.platform === "win32" && ts.getNodeMajorVersion() >= 4;
if (useWatchGuard) {
var currentDrive_1 = extractWatchDirectoryCacheKey(sys.resolvePath(sys.getCurrentDirectory()), undefined);
var statusCache_1 = ts.createMap();
var originalWatchDirectory_1 = sys.watchDirectory;
sys.watchDirectory = function (path, callback, recursive) {
var cacheKey = extractWatchDirectoryCacheKey(path, currentDrive_1);
var status = cacheKey && statusCache_1.get(cacheKey);
if (status === undefined) {
if (logger.hasLevel(server.LogLevel.verbose)) {
logger.info(cacheKey + " for path " + path + " not found in cache...");
}
try {
var args = [ts.combinePaths(__dirname, "watchGuard.js"), path];
if (logger.hasLevel(server.LogLevel.verbose)) {
logger.info("Starting " + process.execPath + " with args " + JSON.stringify(args));
}
childProcess.execFileSync(process.execPath, args, { stdio: "ignore", env: { "ELECTRON_RUN_AS_NODE": "1" } });
status = true;
if (logger.hasLevel(server.LogLevel.verbose)) {
logger.info("WatchGuard for path " + path + " returned: OK");
}
}
catch (e) {
status = false;
if (logger.hasLevel(server.LogLevel.verbose)) {
logger.info("WatchGuard for path " + path + " returned: " + e.message);
}
}
if (cacheKey) {
statusCache_1.set(cacheKey, status);
}
}
else if (logger.hasLevel(server.LogLevel.verbose)) {
logger.info("watchDirectory for " + path + " uses cached drive information.");
}
if (status) {
return originalWatchDirectory_1.call(sys, path, callback, recursive);
}
else {
return { close: function () { } };
}
};
}
sys.write = function (s) { return writeMessage(new Buffer(s, "utf8")); };
sys.watchFile = function (fileName, callback) {
var watchedFile = pollingWatchedFileSet.addFile(fileName, callback);
Expand Down
1 change: 1 addition & 0 deletions lib/tsserverlibrary.d.ts
Expand Up @@ -2216,6 +2216,7 @@ declare namespace ts {
directoryName: string;
referenceCount: number;
}
function getNodeMajorVersion(): number;
let sys: System;
}
declare namespace ts {
Expand Down
27 changes: 19 additions & 8 deletions lib/tsserverlibrary.js
Expand Up @@ -2981,6 +2981,21 @@ var ts;
})(ts || (ts = {}));
var ts;
(function (ts) {
function getNodeMajorVersion() {
if (typeof process === "undefined") {
return undefined;
}
var version = process.version;
if (!version) {
return undefined;
}
var dot = version.indexOf(".");
if (dot === -1) {
return undefined;
}
return parseInt(version.substring(1, dot));
}
ts.getNodeMajorVersion = getNodeMajorVersion;
ts.sys = (function () {
function getWScriptSystem() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
Expand Down Expand Up @@ -3171,9 +3186,8 @@ var ts;
}
}
var watchedFileSet = createWatchedFileSet();
function isNode4OrLater() {
return parseInt(process.version.charAt(1)) >= 4;
}
var nodeVersion = getNodeMajorVersion();
var isNode4OrLater = nodeVersion >= 4;
function isFileSystemCaseSensitive() {
if (platform === "win32" || platform === "win64") {
return false;
Expand Down Expand Up @@ -3312,10 +3326,10 @@ var ts;
},
watchDirectory: function (directoryName, callback, recursive) {
var options;
if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) {
if (!directoryExists(directoryName)) {
return noOpFileWatcher;
}
if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) {
if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) {
options = { persistent: true, recursive: !!recursive };
}
else {
Expand All @@ -3327,9 +3341,6 @@ var ts;
}
;
});
function isUNCPath(s) {
return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47;
}
},
resolvePath: function (path) {
return _path.resolve(path);
Expand Down
1 change: 1 addition & 0 deletions lib/typescript.d.ts
Expand Up @@ -2392,6 +2392,7 @@ declare namespace ts {
directoryName: string;
referenceCount: number;
}
function getNodeMajorVersion(): number;
let sys: System;
}
declare namespace ts {
Expand Down
31 changes: 20 additions & 11 deletions lib/typescript.js
Expand Up @@ -3428,6 +3428,21 @@ var ts;
/// <reference path="core.ts"/>
var ts;
(function (ts) {
function getNodeMajorVersion() {
if (typeof process === "undefined") {
return undefined;
}
var version = process.version;
if (!version) {
return undefined;
}
var dot = version.indexOf(".");
if (dot === -1) {
return undefined;
}
return parseInt(version.substring(1, dot));
}
ts.getNodeMajorVersion = getNodeMajorVersion;
ts.sys = (function () {
function getWScriptSystem() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
Expand Down Expand Up @@ -3628,9 +3643,8 @@ var ts;
}
}
var watchedFileSet = createWatchedFileSet();
function isNode4OrLater() {
return parseInt(process.version.charAt(1)) >= 4;
}
var nodeVersion = getNodeMajorVersion();
var isNode4OrLater = nodeVersion >= 4;
function isFileSystemCaseSensitive() {
// win32\win64 are case insensitive platforms
if (platform === "win32" || platform === "win64") {
Expand Down Expand Up @@ -3782,13 +3796,11 @@ var 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)
var options;
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)
if (!directoryExists(directoryName)) {
// do nothing if target folder does not exist
return noOpFileWatcher;
}
if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) {
if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) {
options = { persistent: true, recursive: !!recursive };
}
else {
Expand All @@ -3804,9 +3816,6 @@ var ts;
}
;
});
function isUNCPath(s) {
return s.length > 2 && s.charCodeAt(0) === 47 /* slash */ && s.charCodeAt(1) === 47 /* slash */;
}
},
resolvePath: function (path) {
return _path.resolve(path);
Expand Down
1 change: 1 addition & 0 deletions lib/typescriptServices.d.ts
Expand Up @@ -2392,6 +2392,7 @@ declare namespace ts {
directoryName: string;
referenceCount: number;
}
function getNodeMajorVersion(): number;
let sys: System;
}
declare namespace ts {
Expand Down
31 changes: 20 additions & 11 deletions lib/typescriptServices.js
Expand Up @@ -3428,6 +3428,21 @@ var ts;
/// <reference path="core.ts"/>
var ts;
(function (ts) {
function getNodeMajorVersion() {
if (typeof process === "undefined") {
return undefined;
}
var version = process.version;
if (!version) {
return undefined;
}
var dot = version.indexOf(".");
if (dot === -1) {
return undefined;
}
return parseInt(version.substring(1, dot));
}
ts.getNodeMajorVersion = getNodeMajorVersion;
ts.sys = (function () {
function getWScriptSystem() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
Expand Down Expand Up @@ -3628,9 +3643,8 @@ var ts;
}
}
var watchedFileSet = createWatchedFileSet();
function isNode4OrLater() {
return parseInt(process.version.charAt(1)) >= 4;
}
var nodeVersion = getNodeMajorVersion();
var isNode4OrLater = nodeVersion >= 4;
function isFileSystemCaseSensitive() {
// win32\win64 are case insensitive platforms
if (platform === "win32" || platform === "win64") {
Expand Down Expand Up @@ -3782,13 +3796,11 @@ var 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)
var options;
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)
if (!directoryExists(directoryName)) {
// do nothing if target folder does not exist
return noOpFileWatcher;
}
if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) {
if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) {
options = { persistent: true, recursive: !!recursive };
}
else {
Expand All @@ -3804,9 +3816,6 @@ var ts;
}
;
});
function isUNCPath(s) {
return s.length > 2 && s.charCodeAt(0) === 47 /* slash */ && s.charCodeAt(1) === 47 /* slash */;
}
},
resolvePath: function (path) {
return _path.resolve(path);
Expand Down

0 comments on commit 510b384

Please sign in to comment.