@@ -72783,52 +72783,74 @@ class OfficialBuilds extends base_distribution_1.default {
7278372783 let toolPath = this.findVersionInHostedToolCacheDirectory();
7278472784 if (toolPath) {
7278572785 core.info(`Found in cache @ ${toolPath}`);
72786+ this.addToolPath(toolPath);
72787+ return;
7278672788 }
72787- else {
72788- let downloadPath = '';
72789- try {
72790- core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
72791- const versionInfo = yield this.getInfoFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
72792- if (versionInfo) {
72793- core.info(`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`);
72794- downloadPath = yield tc.downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.auth);
72795- if (downloadPath) {
72796- toolPath = yield this.extractArchive(downloadPath, versionInfo);
72797- }
72798- }
72799- else {
72800- core.info('Not found in manifest. Falling back to download directly from Node');
72789+ let downloadPath = '';
72790+ try {
72791+ core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
72792+ const versionInfo = yield this.getInfoFromManifest(this.nodeInfo.versionSpec, this.nodeInfo.stable, osArch, manifest);
72793+ if (versionInfo) {
72794+ core.info(`Acquiring ${versionInfo.resolvedVersion} - ${versionInfo.arch} from ${versionInfo.downloadUrl}`);
72795+ downloadPath = yield tc.downloadTool(versionInfo.downloadUrl, undefined, this.nodeInfo.auth);
72796+ if (downloadPath) {
72797+ toolPath = yield this.extractArchive(downloadPath, versionInfo);
7280172798 }
7280272799 }
72803- catch (err) {
72804- // Rate limit?
72805- if (err instanceof tc.HTTPError &&
72806- (err.httpStatusCode === 403 || err.httpStatusCode === 429)) {
72807- core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
72808- }
72809- else {
72810- core.info(err.message);
72811- }
72812- core.debug((_a = err.stack) !== null && _a !== void 0 ? _a : 'empty stack');
72813- core.info('Falling back to download directly from Node');
72814- }
72815- if (!toolPath) {
72816- const nodeJsVersions = yield this.getNodeJsVersions();
72817- const versions = this.filterVersions(nodeJsVersions);
72818- const evaluatedVersion = this.evaluateVersions(versions);
72819- if (!evaluatedVersion) {
72820- throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`);
72821- }
72822- const toolName = this.getNodejsDistInfo(evaluatedVersion);
72823- toolPath = yield this.downloadNodejs(toolName);
72800+ else {
72801+ core.info('Not found in manifest. Falling back to download directly from Node');
72802+ }
72803+ }
72804+ catch (err) {
72805+ // Rate limit?
72806+ if (err instanceof tc.HTTPError &&
72807+ (err.httpStatusCode === 403 || err.httpStatusCode === 429)) {
72808+ core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
72809+ }
72810+ else {
72811+ core.info(err.message);
7282472812 }
72813+ core.debug((_a = err.stack) !== null && _a !== void 0 ? _a : 'empty stack');
72814+ core.info('Falling back to download directly from Node');
72815+ }
72816+ if (!toolPath) {
72817+ toolPath = yield this.downloadDirectlyFromNode();
7282572818 }
7282672819 if (this.osPlat != 'win32') {
7282772820 toolPath = path_1.default.join(toolPath, 'bin');
7282872821 }
7282972822 core.addPath(toolPath);
7283072823 });
7283172824 }
72825+ addToolPath(toolPath) {
72826+ if (this.osPlat != 'win32') {
72827+ toolPath = path_1.default.join(toolPath, 'bin');
72828+ }
72829+ core.addPath(toolPath);
72830+ }
72831+ downloadDirectlyFromNode() {
72832+ return __awaiter(this, void 0, void 0, function* () {
72833+ const nodeJsVersions = yield this.getNodeJsVersions();
72834+ const versions = this.filterVersions(nodeJsVersions);
72835+ const evaluatedVersion = this.evaluateVersions(versions);
72836+ if (!evaluatedVersion) {
72837+ throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`);
72838+ }
72839+ const toolName = this.getNodejsDistInfo(evaluatedVersion);
72840+ try {
72841+ const toolPath = yield this.downloadNodejs(toolName);
72842+ return toolPath;
72843+ }
72844+ catch (error) {
72845+ if (error instanceof tc.HTTPError && error.httpStatusCode === 404) {
72846+ core.info(`Node version ${this.nodeInfo.versionSpec} for platform ${this.osPlat} and architecture ${this.nodeInfo.arch} was found but failed to download. ` +
72847+ 'This usually happens when downloadable binaries are not fully updated at https://nodejs.org/. ' +
72848+ 'To resolve this issue you may either fall back to the older version or try again later.');
72849+ }
72850+ throw error;
72851+ }
72852+ });
72853+ }
7283272854 evaluateVersions(versions) {
7283372855 let version = '';
7283472856 if (this.isLatestSyntax(this.nodeInfo.versionSpec)) {
0 commit comments