mirror of
https://github.com/actions/setup-node.git
synced 2025-07-25 16:08:25 +02:00
optimize code
This commit is contained in:
parent
15798eaae7
commit
785620d55b
6 changed files with 16 additions and 92 deletions
|
@ -24,7 +24,6 @@ export default abstract class BaseDistribution {
|
|||
}
|
||||
|
||||
protected abstract getDistributionUrl(): string;
|
||||
protected abstract getNodejsVersions(): Promise<INodeVersion[]>;
|
||||
protected abstract evaluateVersions(nodeVersions: string[]): string;
|
||||
|
||||
public async getNodeJsInfo() {
|
||||
|
@ -48,6 +47,14 @@ export default abstract class BaseDistribution {
|
|||
return tc.find('node', this.nodeInfo.versionSpec, this.nodeInfo.arch);
|
||||
}
|
||||
|
||||
protected async getNodejsVersions(): Promise<INodeVersion[]> {
|
||||
const initialUrl = this.getDistributionUrl();
|
||||
const dataUrl = `${initialUrl}/index.json`;
|
||||
|
||||
let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
|
||||
return response.result || [];
|
||||
}
|
||||
|
||||
protected getNodejsDistInfo(version: string, osPlat: string) {
|
||||
let osArch: string = this.translateArchToDistUrl(this.nodeInfo.arch);
|
||||
version = semver.clean(version) || '';
|
||||
|
|
|
@ -69,14 +69,6 @@ export default class NightlyNodejs extends BaseDistribution {
|
|||
return 'https://nodejs.org/download/nightly';
|
||||
}
|
||||
|
||||
async getNodejsVersions(): Promise<INodeVersion[]> {
|
||||
const initialUrl = this.getDistributionUrl();
|
||||
const dataUrl = `${initialUrl}/index.json`;
|
||||
|
||||
let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
|
||||
return response.result || [];
|
||||
}
|
||||
|
||||
protected createRangePreRelease(
|
||||
versionSpec: string,
|
||||
distribution: string = ''
|
||||
|
|
|
@ -131,14 +131,6 @@ export default class OfficialBuilds extends BaseDistribution {
|
|||
return `https://nodejs.org/dist`;
|
||||
}
|
||||
|
||||
protected async getNodejsVersions(): Promise<INodeVersion[]> {
|
||||
const initialUrl = this.getDistributionUrl();
|
||||
const dataUrl = `${initialUrl}/index.json`;
|
||||
|
||||
let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
|
||||
return response.result || [];
|
||||
}
|
||||
|
||||
private getManifest(): Promise<tc.IToolRelease[]> {
|
||||
core.debug('Getting manifest from actions/node-versions@main');
|
||||
return tc.getManifestFromRepo(
|
||||
|
|
|
@ -10,14 +10,6 @@ export default class RcBuild extends BaseDistribution {
|
|||
super(nodeInfo);
|
||||
}
|
||||
|
||||
protected async getNodejsVersions(): Promise<INodeVersion[]> {
|
||||
const initialUrl = this.getDistributionUrl();
|
||||
const dataUrl = `${initialUrl}/index.json`;
|
||||
|
||||
let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
|
||||
return response.result || [];
|
||||
}
|
||||
|
||||
protected evaluateVersions(versions: string[]): string {
|
||||
let version = '';
|
||||
|
||||
|
|
|
@ -70,14 +70,6 @@ export default class CanaryBuild extends BaseDistribution {
|
|||
return version;
|
||||
}
|
||||
|
||||
async getNodejsVersions(): Promise<INodeVersion[]> {
|
||||
const initialUrl = this.getDistributionUrl();
|
||||
const dataUrl = `${initialUrl}/index.json`;
|
||||
|
||||
let response = await this.httpClient.getJson<INodeVersion[]>(dataUrl);
|
||||
return response.result || [];
|
||||
}
|
||||
|
||||
protected createRangePreRelease(
|
||||
versionSpec: string,
|
||||
distribution: string = ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue