mirror of
				https://kkgithub.com/actions/setup-node.git
				synced 2025-11-04 04:31:55 +08:00 
			
		
		
		
	Get correct url for arm dist
This commit is contained in:
		@ -25,7 +25,7 @@ const os = __importStar(require("os"));
 | 
			
		||||
const path = __importStar(require("path"));
 | 
			
		||||
const semver = __importStar(require("semver"));
 | 
			
		||||
let osPlat = os.platform();
 | 
			
		||||
let osArch = os.arch();
 | 
			
		||||
let osArch = translateArchToDistUrl(os.arch());
 | 
			
		||||
if (!tempDirectory) {
 | 
			
		||||
    let baseLocation;
 | 
			
		||||
    if (process.platform === 'win32') {
 | 
			
		||||
@ -90,13 +90,13 @@ function queryLatestMatch(versionSpec) {
 | 
			
		||||
        let dataFileName;
 | 
			
		||||
        switch (osPlat) {
 | 
			
		||||
            case 'linux':
 | 
			
		||||
                dataFileName = 'linux-' + osArch;
 | 
			
		||||
                dataFileName = `linux-${osArch}`;
 | 
			
		||||
                break;
 | 
			
		||||
            case 'darwin':
 | 
			
		||||
                dataFileName = 'osx-' + osArch + '-tar';
 | 
			
		||||
                dataFileName = `osx-${osArch}-tar`;
 | 
			
		||||
                break;
 | 
			
		||||
            case 'win32':
 | 
			
		||||
                dataFileName = 'win-' + osArch + '-exe';
 | 
			
		||||
                dataFileName = `win-${osArch}-exe`;
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                throw new Error(`Unexpected OS '${osPlat}'`);
 | 
			
		||||
@ -149,10 +149,10 @@ function acquireNode(version) {
 | 
			
		||||
        //
 | 
			
		||||
        version = semver.clean(version) || '';
 | 
			
		||||
        let fileName = osPlat == 'win32'
 | 
			
		||||
            ? 'node-v' + version + '-win-' + os.arch()
 | 
			
		||||
            : 'node-v' + version + '-' + osPlat + '-' + os.arch();
 | 
			
		||||
        let urlFileName = osPlat == 'win32' ? fileName + '.7z' : fileName + '.tar.gz';
 | 
			
		||||
        let downloadUrl = 'https://nodejs.org/dist/v' + version + '/' + urlFileName;
 | 
			
		||||
            ? `node-v${version}-win-${osArch}`
 | 
			
		||||
            : `node-v${version}-${osPlat}-${osArch}`;
 | 
			
		||||
        let urlFileName = osPlat == 'win32' ? `${fileName}.7z` : `${fileName}.tar.gz`;
 | 
			
		||||
        let downloadUrl = `https://nodejs.org/dist/v${version}/${urlFileName}`;
 | 
			
		||||
        let downloadPath;
 | 
			
		||||
        try {
 | 
			
		||||
            downloadPath = yield tc.downloadTool(downloadUrl);
 | 
			
		||||
@ -202,8 +202,8 @@ function acquireNodeFromFallbackLocation(version) {
 | 
			
		||||
        let exeUrl;
 | 
			
		||||
        let libUrl;
 | 
			
		||||
        try {
 | 
			
		||||
            exeUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
 | 
			
		||||
            libUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;
 | 
			
		||||
            exeUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.exe`;
 | 
			
		||||
            libUrl = `https://nodejs.org/dist/v${version}/win-${osArch}/node.lib`;
 | 
			
		||||
            const exePath = yield tc.downloadTool(exeUrl);
 | 
			
		||||
            yield io.cp(exePath, path.join(tempDir, 'node.exe'));
 | 
			
		||||
            const libPath = yield tc.downloadTool(libUrl);
 | 
			
		||||
@ -225,3 +225,13 @@ function acquireNodeFromFallbackLocation(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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user