1
0
Fork 0
mirror of https://code.forgejo.org/actions/setup-node synced 2025-06-09 05:22:20 +02:00

Add tests

This commit is contained in:
Danny McCormick 2019-06-04 16:00:18 -04:00
parent eac926003b
commit 48c62836f2
8 changed files with 5250 additions and 54 deletions

View file

@ -62,9 +62,7 @@ function getNode(versionSpec) {
}
//
// prepend the tools path. instructs the agent to prepend for future tasks
//
// TODO - addPath not implemented yet (this should probably actually be in core)
// tc.addPath(toolPath);
core.addPath(toolPath);
});
}
exports.getNode = getNode;
@ -145,6 +143,9 @@ function acquireNode(version) {
if (err['httpStatusCode'] && err['httpStatusCode'] === '404') {
return yield acquireNodeFromFallbackLocation(version);
}
else {
console.log('Message', err.message.statusCode);
}
throw err;
}
//
@ -152,12 +153,7 @@ function acquireNode(version) {
//
let extPath;
if (osPlat == 'win32') {
extPath = getAgentTemp();
if (!extPath) {
throw new Error('Expected Agent.TempDirectory to be set');
}
let _7zPath = path.join(__dirname, '7zr.exe');
extPath = yield tc.extract7z(downloadPath, extPath);
extPath = yield tc.extract7z(downloadPath);
}
else {
extPath = yield tc.extractTar(downloadPath);
@ -185,7 +181,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(getAgentTemp(), tempDownloadFolder);
let tempDir = path.join(__dirname, tempDownloadFolder);
yield io.mkdirP(tempDir);
let exeUrl;
let libUrl;
@ -213,11 +209,3 @@ function acquireNodeFromFallbackLocation(version) {
return yield tc.cacheDir(tempDir, 'node', version);
});
}
function getAgentTemp() {
// TODO - we need an actual protocol for this (this is just a placeholder)
const tempDirectory = process.env['Runner.TempDirectory'];
if (!tempDirectory) {
throw new Error('Runner.TempDirectory is not set');
}
return tempDirectory;
}