mirror of
https://github.com/actions/setup-node.git
synced 2025-09-17 20:24:00 +08:00
Add tests
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user