diff --git a/lib/tsc.js b/lib/tsc.js index 54e563e80cef4..29eed460b7e69 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -60,7 +60,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook var ts; (function (ts) { ts.versionMajorMinor = "3.4"; - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { ts.emptyArray = []; diff --git a/lib/tsserver.js b/lib/tsserver.js index 81e0cb7e64c57..5ec760d252c66 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -85,7 +85,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.4"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -123104,6 +123104,11 @@ var ts; * typingsInstaller will run the command with `${npmLocation} install ...`. */ Arguments.NpmLocation = "--npmLocation"; + /** + * Flag indicating that the typings installer should try to validate the default npm location. + * If the default npm is not found when this flag is enabled, fallback to `npm install` + */ + Arguments.ValidateDefaultNpmLocation = "--validateDefaultNpmLocation"; })(Arguments = server.Arguments || (server.Arguments = {})); function hasArgument(argumentName) { return ts.sys.args.indexOf(argumentName) >= 0; @@ -131462,7 +131467,7 @@ var ts; return Logger; }()); var NodeTypingsInstaller = /** @class */ (function () { - function NodeTypingsInstaller(telemetryEnabled, logger, host, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, event) { + function NodeTypingsInstaller(telemetryEnabled, logger, host, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, validateDefaultNpmLocation, event) { this.telemetryEnabled = telemetryEnabled; this.logger = logger; this.host = host; @@ -131470,6 +131475,7 @@ var ts; this.typingSafeListLocation = typingSafeListLocation; this.typesMapLocation = typesMapLocation; this.npmLocation = npmLocation; + this.validateDefaultNpmLocation = validateDefaultNpmLocation; this.event = event; this.activeRequestCount = 0; this.requestQueue = []; @@ -131526,6 +131532,9 @@ var ts; if (this.npmLocation) { args.push(server.Arguments.NpmLocation, this.npmLocation); } + if (this.validateDefaultNpmLocation) { + args.push(server.Arguments.ValidateDefaultNpmLocation); + } var execArgv = []; for (var _i = 0, _a = process.execArgv; _i < _a.length; _i++) { var arg = _a[_i]; @@ -131710,7 +131719,7 @@ var ts; var host = sys; var typingsInstaller = disableAutomaticTypingAcquisition ? undefined - : new NodeTypingsInstaller(telemetryEnabled, logger, host, getGlobalTypingsCacheLocation(), typingSafeListLocation, typesMapLocation, npmLocation, event); + : new NodeTypingsInstaller(telemetryEnabled, logger, host, getGlobalTypingsCacheLocation(), typingSafeListLocation, typesMapLocation, npmLocation, validateDefaultNpmLocation, event); _this = _super.call(this, { host: host, cancellationToken: cancellationToken, @@ -132105,6 +132114,7 @@ var ts; var typingSafeListLocation = server.findArgument(server.Arguments.TypingSafeListLocation); // TODO: GH#18217 var typesMapLocation = server.findArgument(server.Arguments.TypesMapLocation) || ts.combinePaths(ts.getDirectoryPath(sys.getExecutingFilePath()), "typesMap.json"); var npmLocation = server.findArgument(server.Arguments.NpmLocation); + var validateDefaultNpmLocation = server.hasArgument(server.Arguments.ValidateDefaultNpmLocation); function parseStringArray(argName) { var arg = server.findArgument(argName); if (arg === undefined) { diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 54c3e4a50d18c..0b0f811167e24 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -84,7 +84,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.4"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -94853,6 +94853,11 @@ var ts; * typingsInstaller will run the command with `${npmLocation} install ...`. */ Arguments.NpmLocation = "--npmLocation"; + /** + * Flag indicating that the typings installer should try to validate the default npm location. + * If the default npm is not found when this flag is enabled, fallback to `npm install` + */ + Arguments.ValidateDefaultNpmLocation = "--validateDefaultNpmLocation"; })(Arguments = server.Arguments || (server.Arguments = {})); function hasArgument(argumentName) { return ts.sys.args.indexOf(argumentName) >= 0; diff --git a/lib/typescript.js b/lib/typescript.js index 1e462e6044707..8a87b339a32f5 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -75,7 +75,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.4"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -94844,6 +94844,11 @@ var ts; * typingsInstaller will run the command with `${npmLocation} install ...`. */ Arguments.NpmLocation = "--npmLocation"; + /** + * Flag indicating that the typings installer should try to validate the default npm location. + * If the default npm is not found when this flag is enabled, fallback to `npm install` + */ + Arguments.ValidateDefaultNpmLocation = "--validateDefaultNpmLocation"; })(Arguments = server.Arguments || (server.Arguments = {})); function hasArgument(argumentName) { return ts.sys.args.indexOf(argumentName) >= 0; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 696cb60201252..fc0ce0febb7b5 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -75,7 +75,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.4"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -94844,6 +94844,11 @@ var ts; * typingsInstaller will run the command with `${npmLocation} install ...`. */ Arguments.NpmLocation = "--npmLocation"; + /** + * Flag indicating that the typings installer should try to validate the default npm location. + * If the default npm is not found when this flag is enabled, fallback to `npm install` + */ + Arguments.ValidateDefaultNpmLocation = "--validateDefaultNpmLocation"; })(Arguments = server.Arguments || (server.Arguments = {})); function hasArgument(argumentName) { return ts.sys.args.indexOf(argumentName) >= 0; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 779668a162ae1..d5a364f4604ec 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -76,7 +76,7 @@ var ts; // If changing the text in this section, be sure to test `configureNightly` too. ts.versionMajorMinor = "3.4"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".5"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -94845,6 +94845,11 @@ var ts; * typingsInstaller will run the command with `${npmLocation} install ...`. */ Arguments.NpmLocation = "--npmLocation"; + /** + * Flag indicating that the typings installer should try to validate the default npm location. + * If the default npm is not found when this flag is enabled, fallback to `npm install` + */ + Arguments.ValidateDefaultNpmLocation = "--validateDefaultNpmLocation"; })(Arguments = server.Arguments || (server.Arguments = {})); function hasArgument(argumentName) { return ts.sys.args.indexOf(argumentName) >= 0; @@ -95663,13 +95668,17 @@ var ts; } return FileLog; }()); - function getDefaultNPMLocation(processName) { + function getDefaultNPMLocation(processName, validateDefaultNpmLocation, host) { if (path.basename(processName).indexOf("node") === 0) { - return "\"" + path.join(path.dirname(process.argv[0]), "npm") + "\""; - } - else { - return "npm"; + var npmPath = path.join(path.dirname(process.argv[0]), "npm"); + if (!validateDefaultNpmLocation) { + return npmPath; + } + if (host.fileExists(npmPath)) { + return "\"" + npmPath + "\""; + } } + return "npm"; } function loadTypesRegistryFile(typesRegistryFilePath, host, log) { if (!host.fileExists(typesRegistryFilePath)) { @@ -95695,15 +95704,16 @@ var ts; } var NodeTypingsInstaller = (function (_super) { __extends(NodeTypingsInstaller, _super); - function NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, throttleLimit, log) { + function NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, validateDefaultNpmLocation, throttleLimit, log) { var _this = _super.call(this, ts.sys, globalTypingsCacheLocation, typingSafeListLocation ? ts.toPath(typingSafeListLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), typesMapLocation ? ts.toPath(typesMapLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typesMap.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; - _this.npmPath = npmLocation !== undefined ? npmLocation : getDefaultNPMLocation(process.argv[0]); + _this.npmPath = npmLocation !== undefined ? npmLocation : getDefaultNPMLocation(process.argv[0], validateDefaultNpmLocation, _this.installTypingHost); if (ts.stringContains(_this.npmPath, " ") && _this.npmPath[0] !== "\"") { _this.npmPath = "\"" + _this.npmPath + "\""; } if (_this.log.isEnabled()) { _this.log.writeLine("Process id: " + process.pid); _this.log.writeLine("NPM location: " + _this.npmPath + " (explicit '" + server.Arguments.NpmLocation + "' " + (npmLocation === undefined ? "not " : "") + " provided)"); + _this.log.writeLine("validateDefaultNpmLocation: " + validateDefaultNpmLocation); } (_this.nodeExecSync = require("child_process").execSync); _this.ensurePackageDirectoryExists(globalTypingsCacheLocation); @@ -95830,6 +95840,7 @@ var ts; var typingSafeListLocation = server.findArgument(server.Arguments.TypingSafeListLocation); var typesMapLocation = server.findArgument(server.Arguments.TypesMapLocation); var npmLocation = server.findArgument(server.Arguments.NpmLocation); + var validateDefaultNpmLocation = server.hasArgument(server.Arguments.ValidateDefaultNpmLocation); var log = new FileLog(logFilePath); if (log.isEnabled()) { process.on("uncaughtException", function (e) { @@ -95842,7 +95853,7 @@ var ts; } process.exit(0); }); - var installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, 5, log); + var installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, validateDefaultNpmLocation, 5, log); installer.listen(); function indent(newline, str) { return newline + " " + str.replace(/\r?\n/, newline + " ");