Merge pull request #88 from actions/arm-installer
Get correct url for arm dist
This commit is contained in:
parent
8de2f9fcbc
commit
b6651e20e5
@ -25,7 +25,7 @@ const os = __importStar(require("os"));
|
|||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
let osPlat = os.platform();
|
let osPlat = os.platform();
|
||||||
let osArch = os.arch();
|
let osArch = translateArchToDistUrl(os.arch());
|
||||||
if (!tempDirectory) {
|
if (!tempDirectory) {
|
||||||
let baseLocation;
|
let baseLocation;
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
@ -90,13 +90,13 @@ function queryLatestMatch(versionSpec) {
|
|||||||
let dataFileName;
|
let dataFileName;
|
||||||
switch (osPlat) {
|
switch (osPlat) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
dataFileName = 'linux-' + osArch;
|
dataFileName = `linux-${osArch}`;
|
||||||
break;
|
break;
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
dataFileName = 'osx-' + osArch + '-tar';
|
dataFileName = `osx-${osArch}-tar`;
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
dataFileName = 'win-' + osArch + '-exe';
|
dataFileName = `win-${osArch}-exe`;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unexpected OS '${osPlat}'`);
|
throw new Error(`Unexpected OS '${osPlat}'`);
|
||||||
@ -149,10 +149,10 @@ function acquireNode(version) {
|
|||||||
//
|
//
|
||||||
version = semver.clean(version) || '';
|
version = semver.clean(version) || '';
|
||||||
let fileName = osPlat == 'win32'
|
let fileName = osPlat == 'win32'
|
||||||
? 'node-v' + version + '-win-' + os.arch()
|
? `node-v${version}-win-${osArch}`
|
||||||
: 'node-v' + version + '-' + osPlat + '-' + os.arch();
|
: `node-v${version}-${osPlat}-${osArch}`;
|
||||||
let urlFileName = osPlat == 'win32' ? fileName + '.7z' : fileName + '.tar.gz';
|
let urlFileName = osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
|
||||||
let downloadUrl = 'https://nodejs.org/dist/v' + version + '/' + urlFileName;
|
let downloadUrl = `https://nodejs.org/dist/v${version}/${urlFileName}`;
|
||||||
let downloadPath;
|
let downloadPath;
|
||||||
try {
|
try {
|
||||||
downloadPath = yield tc.downloadTool(downloadUrl);
|
downloadPath = yield tc.downloadTool(downloadUrl);
|
||||||
@ -202,8 +202,8 @@ function acquireNodeFromFallbackLocation(version) {
|
|||||||
let exeUrl;
|
let exeUrl;
|
||||||
let libUrl;
|
let libUrl;
|
||||||
try {
|
try {
|
||||||
exeUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
|
exeUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.exe`;
|
||||||
libUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;
|
libUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.lib`;
|
||||||
const exePath = yield tc.downloadTool(exeUrl);
|
const exePath = yield tc.downloadTool(exeUrl);
|
||||||
yield io.cp(exePath, path.join(tempDir, 'node.exe'));
|
yield io.cp(exePath, path.join(tempDir, 'node.exe'));
|
||||||
const libPath = yield tc.downloadTool(libUrl);
|
const libPath = yield tc.downloadTool(libUrl);
|
||||||
@ -225,3 +225,13 @@ function acquireNodeFromFallbackLocation(version) {
|
|||||||
return yield tc.cacheDir(tempDir, 'node', version);
|
return yield tc.cacheDir(tempDir, 'node', version);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// os.arch does not always match the relative download url, e.g.
|
||||||
|
// os.arch == 'arm' != node-v12.13.1-linux-armv7l.tar.gz
|
||||||
|
function translateArchToDistUrl(arch) {
|
||||||
|
switch (arch) {
|
||||||
|
case 'arm':
|
||||||
|
return 'armv7l';
|
||||||
|
default:
|
||||||
|
return arch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -9,7 +9,7 @@ import * as path from 'path';
|
|||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
|
||||||
let osPlat: string = os.platform();
|
let osPlat: string = os.platform();
|
||||||
let osArch: string = os.arch();
|
let osArch: string = translateArchToDistUrl(os.arch());
|
||||||
|
|
||||||
if (!tempDirectory) {
|
if (!tempDirectory) {
|
||||||
let baseLocation;
|
let baseLocation;
|
||||||
@ -86,13 +86,13 @@ async function queryLatestMatch(versionSpec: string): Promise<string> {
|
|||||||
let dataFileName: string;
|
let dataFileName: string;
|
||||||
switch (osPlat) {
|
switch (osPlat) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
dataFileName = 'linux-' + osArch;
|
dataFileName = `linux-${osArch}`;
|
||||||
break;
|
break;
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
dataFileName = 'osx-' + osArch + '-tar';
|
dataFileName = `osx-${osArch}-tar`;
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
dataFileName = 'win-' + osArch + '-exe';
|
dataFileName = `win-${osArch}-exe`;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unexpected OS '${osPlat}'`);
|
throw new Error(`Unexpected OS '${osPlat}'`);
|
||||||
@ -150,12 +150,11 @@ async function acquireNode(version: string): Promise<string> {
|
|||||||
version = semver.clean(version) || '';
|
version = semver.clean(version) || '';
|
||||||
let fileName: string =
|
let fileName: string =
|
||||||
osPlat == 'win32'
|
osPlat == 'win32'
|
||||||
? 'node-v' + version + '-win-' + os.arch()
|
? `node-v${version}-win-${osArch}`
|
||||||
: 'node-v' + version + '-' + osPlat + '-' + os.arch();
|
: `node-v${version}-${osPlat}-${osArch}`;
|
||||||
let urlFileName: string =
|
let urlFileName: string =
|
||||||
osPlat == 'win32' ? fileName + '.7z' : fileName + '.tar.gz';
|
osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
|
||||||
|
let downloadUrl = `https://nodejs.org/dist/v${version}/${urlFileName}`;
|
||||||
let downloadUrl = 'https://nodejs.org/dist/v' + version + '/' + urlFileName;
|
|
||||||
|
|
||||||
let downloadPath: string;
|
let downloadPath: string;
|
||||||
|
|
||||||
@ -210,8 +209,8 @@ async function acquireNodeFromFallbackLocation(
|
|||||||
let exeUrl: string;
|
let exeUrl: string;
|
||||||
let libUrl: string;
|
let libUrl: string;
|
||||||
try {
|
try {
|
||||||
exeUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
|
exeUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.exe`;
|
||||||
libUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;
|
libUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.lib`;
|
||||||
|
|
||||||
const exePath = await tc.downloadTool(exeUrl);
|
const exePath = await tc.downloadTool(exeUrl);
|
||||||
await io.cp(exePath, path.join(tempDir, 'node.exe'));
|
await io.cp(exePath, path.join(tempDir, 'node.exe'));
|
||||||
@ -232,3 +231,17 @@ async function acquireNodeFromFallbackLocation(
|
|||||||
}
|
}
|
||||||
return await tc.cacheDir(tempDir, 'node', version);
|
return await tc.cacheDir(tempDir, 'node', version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// os.arch does not always match the relative download url, e.g.
|
||||||
|
// os.arch == 'arm' != node-v12.13.1-linux-armv7l.tar.gz
|
||||||
|
// All other currently supported architectures match, e.g.:
|
||||||
|
// os.arch = arm64 => https://nodejs.org/dist/v{VERSION}/node-v{VERSION}-{OS}-arm64.tar.gz
|
||||||
|
// os.arch = x64 => https://nodejs.org/dist/v{VERSION}/node-v{VERSION}-{OS}-x64.tar.gz
|
||||||
|
function translateArchToDistUrl(arch: string): string {
|
||||||
|
switch (arch) {
|
||||||
|
case 'arm':
|
||||||
|
return 'armv7l';
|
||||||
|
default:
|
||||||
|
return arch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user