mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-06-08 21:21:12 +00:00
Expand node version file support to include lts based codenames
This commit is contained in:
parent
c3812bd36a
commit
a0d376d3fa
7 changed files with 311 additions and 43 deletions
|
@ -1,21 +1,12 @@
|
|||
import os = require('os');
|
||||
import * as assert from 'assert';
|
||||
import * as core from '@actions/core';
|
||||
import * as hc from '@actions/http-client';
|
||||
import * as io from '@actions/io';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import fs = require('fs');
|
||||
|
||||
//
|
||||
// Node versions interface
|
||||
// see https://nodejs.org/dist/index.json
|
||||
//
|
||||
export interface INodeVersion {
|
||||
version: string;
|
||||
files: string[];
|
||||
}
|
||||
import {INodeVersion, getVersionsFromDist} from './node-version';
|
||||
|
||||
interface INodeVersionInfo {
|
||||
downloadUrl: string;
|
||||
|
@ -274,7 +265,7 @@ async function queryDistForMatch(versionSpec: string): Promise<string> {
|
|||
}
|
||||
|
||||
let versions: string[] = [];
|
||||
let nodeVersions = await module.exports.getVersionsFromDist();
|
||||
let nodeVersions = await getVersionsFromDist();
|
||||
|
||||
nodeVersions.forEach((nodeVersion: INodeVersion) => {
|
||||
// ensure this version supports your os and platform
|
||||
|
@ -288,16 +279,6 @@ async function queryDistForMatch(versionSpec: string): Promise<string> {
|
|||
return version;
|
||||
}
|
||||
|
||||
export async function getVersionsFromDist(): Promise<INodeVersion[]> {
|
||||
let dataUrl = 'https://nodejs.org/dist/index.json';
|
||||
let httpClient = new hc.HttpClient('setup-node', [], {
|
||||
allowRetries: true,
|
||||
maxRetries: 3
|
||||
});
|
||||
let response = await httpClient.getJson<INodeVersion[]>(dataUrl);
|
||||
return response.result || [];
|
||||
}
|
||||
|
||||
// For non LTS versions of Node, the files we need (for Windows) are sometimes located
|
||||
// in a different folder than they normally are for other versions.
|
||||
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue