Update index.js

This commit is contained in:
Dmitry Shibanov 2023-10-23 13:30:53 +02:00
parent 92309f6248
commit 6cf1d17ac0

34
dist/setup/index.js vendored
View file

@ -93398,8 +93398,9 @@ class OfficialBuilds extends base_distribution_1.default {
let toolPath = this.findVersionInHostedToolCacheDirectory(); let toolPath = this.findVersionInHostedToolCacheDirectory();
if (toolPath) { if (toolPath) {
core.info(`Found in cache @ ${toolPath}`); core.info(`Found in cache @ ${toolPath}`);
this.addToolPath(toolPath);
return;
} }
else {
let downloadPath = ''; let downloadPath = '';
try { try {
core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`); core.info(`Attempting to download ${this.nodeInfo.versionSpec}...`);
@ -93424,10 +93425,26 @@ class OfficialBuilds extends base_distribution_1.default {
else { else {
core.info(err.message); core.info(err.message);
} }
core.debug((_a = err.stack) !== null && _a !== void 0 ? _a : 'No stack trace'); core.debug((_a = err.stack) !== null && _a !== void 0 ? _a : 'empty stack');
core.info('Falling back to download directly from Node'); core.info('Falling back to download directly from Node');
} }
if (!toolPath) { if (!toolPath) {
toolPath = yield this.downloadDirectlyFromNode();
}
if (this.osPlat != 'win32') {
toolPath = path_1.default.join(toolPath, 'bin');
}
core.addPath(toolPath);
});
}
addToolPath(toolPath) {
if (this.osPlat != 'win32') {
toolPath = path_1.default.join(toolPath, 'bin');
}
core.addPath(toolPath);
}
downloadDirectlyFromNode() {
return __awaiter(this, void 0, void 0, function* () {
const nodeJsVersions = yield this.getNodeJsVersions(); const nodeJsVersions = yield this.getNodeJsVersions();
const versions = this.filterVersions(nodeJsVersions); const versions = this.filterVersions(nodeJsVersions);
const evaluatedVersion = this.evaluateVersions(versions); const evaluatedVersion = this.evaluateVersions(versions);
@ -93435,13 +93452,18 @@ class OfficialBuilds extends base_distribution_1.default {
throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`); throw new Error(`Unable to find Node version '${this.nodeInfo.versionSpec}' for platform ${this.osPlat} and architecture ${this.nodeInfo.arch}.`);
} }
const toolName = this.getNodejsDistInfo(evaluatedVersion); const toolName = this.getNodejsDistInfo(evaluatedVersion);
toolPath = yield this.downloadNodejs(toolName); try {
const toolPath = yield this.downloadNodejs(toolName);
return toolPath;
} }
catch (error) {
if (error instanceof tc.HTTPError && error.httpStatusCode === 404) {
core.warning(`Node version ${this.nodeInfo.versionSpec} for platform ${this.osPlat} and architecture ${this.nodeInfo.arch} was found but failed to download. ` +
'This usually happens when downloadable binaries are not fully updated at https://nodejs.org/. ' +
'To resolve this issue you may either fall back to the older version or try again later.');
} }
if (this.osPlat != 'win32') { throw error;
toolPath = path_1.default.join(toolPath, 'bin');
} }
core.addPath(toolPath);
}); });
} }
evaluateVersions(versions) { evaluateVersions(versions) {