mirror of
https://code.forgejo.org/actions/setup-node
synced 2025-06-22 11:18:00 +02:00
Update tool-cache we consume
This commit is contained in:
parent
d83862c273
commit
d7b6952411
18 changed files with 230 additions and 163 deletions
|
@ -15,6 +15,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// Load tempDirectory before it gets wiped by tool-cache
|
||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const io = __importStar(require("@actions/io"));
|
||||
const tc = __importStar(require("@actions/tool-cache"));
|
||||
|
@ -24,6 +26,22 @@ const path = __importStar(require("path"));
|
|||
const semver = __importStar(require("semver"));
|
||||
let osPlat = os.platform();
|
||||
let osArch = os.arch();
|
||||
if (!tempDirectory) {
|
||||
let baseLocation;
|
||||
if (process.platform === 'win32') {
|
||||
// On windows use the USERPROFILE env variable
|
||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||
}
|
||||
else {
|
||||
if (process.platform === 'darwin') {
|
||||
baseLocation = '/Users';
|
||||
}
|
||||
else {
|
||||
baseLocation = '/home';
|
||||
}
|
||||
}
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||
}
|
||||
function getNode(versionSpec) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// check cache
|
||||
|
@ -140,7 +158,7 @@ function acquireNode(version) {
|
|||
downloadPath = yield tc.downloadTool(downloadUrl);
|
||||
}
|
||||
catch (err) {
|
||||
if (err['httpStatusCode'] && err['httpStatusCode'] === '404') {
|
||||
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
|
||||
return yield acquireNodeFromFallbackLocation(version);
|
||||
}
|
||||
throw err;
|
||||
|
@ -179,7 +197,7 @@ function acquireNodeFromFallbackLocation(version) {
|
|||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Create temporary folder to download in to
|
||||
let tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000);
|
||||
let tempDir = path.join(__dirname, tempDownloadFolder);
|
||||
let tempDir = path.join(tempDirectory, tempDownloadFolder);
|
||||
yield io.mkdirP(tempDir);
|
||||
let exeUrl;
|
||||
let libUrl;
|
||||
|
@ -192,7 +210,7 @@ function acquireNodeFromFallbackLocation(version) {
|
|||
yield io.mv(libPath, path.join(tempDir, 'node.lib'));
|
||||
}
|
||||
catch (err) {
|
||||
if (err['httpStatusCode'] && err['httpStatusCode'] === '404') {
|
||||
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
|
||||
exeUrl = `https://nodejs.org/dist/v${version}/node.exe`;
|
||||
libUrl = `https://nodejs.org/dist/v${version}/node.lib`;
|
||||
const exePath = yield tc.downloadTool(exeUrl);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue