mirror of
https://github.com/actions/setup-node.git
synced 2025-06-29 14:13:49 +00:00
updated test cases
This commit is contained in:
parent
e5561a4d32
commit
7a5031f96f
9 changed files with 172 additions and 272 deletions
|
@ -10,17 +10,7 @@ export default class NightlyNodejs extends BasePrereleaseNodejs {
|
|||
|
||||
protected getDistributionUrl(): string {
|
||||
if (this.nodeInfo.mirrorURL) {
|
||||
if (this.nodeInfo.mirrorURL != '') {
|
||||
return this.nodeInfo.mirrorURL;
|
||||
} else {
|
||||
if (this.nodeInfo.mirrorURL === '') {
|
||||
throw new Error(
|
||||
'Mirror URL is empty. Please provide a valid mirror URL.'
|
||||
);
|
||||
} else {
|
||||
throw new Error('Mirror URL is not a valid');
|
||||
}
|
||||
}
|
||||
return this.nodeInfo.mirrorURL;
|
||||
} else {
|
||||
return 'https://nodejs.org/download/nightly';
|
||||
}
|
||||
|
|
|
@ -7,17 +7,7 @@ export default class RcBuild extends BaseDistribution {
|
|||
}
|
||||
protected getDistributionUrl(): string {
|
||||
if (this.nodeInfo.mirrorURL) {
|
||||
if (this.nodeInfo.mirrorURL != '') {
|
||||
return this.nodeInfo.mirrorURL;
|
||||
} else {
|
||||
if (this.nodeInfo.mirrorURL === '') {
|
||||
throw new Error(
|
||||
'Mirror URL is empty. Please provide a valid mirror URL.'
|
||||
);
|
||||
} else {
|
||||
throw new Error('Mirror URL is not a valid');
|
||||
}
|
||||
}
|
||||
return this.nodeInfo.mirrorURL;
|
||||
} else {
|
||||
return 'https://nodejs.org/download/rc';
|
||||
}
|
||||
|
|
|
@ -8,17 +8,7 @@ export default class CanaryBuild extends BasePrereleaseNodejs {
|
|||
|
||||
protected getDistributionUrl(): string {
|
||||
if (this.nodeInfo.mirrorURL) {
|
||||
if (this.nodeInfo.mirrorURL != '') {
|
||||
return this.nodeInfo.mirrorURL;
|
||||
} else {
|
||||
if (this.nodeInfo.mirrorURL === '') {
|
||||
throw new Error(
|
||||
'Mirror URL is empty. Please provide a valid mirror URL.'
|
||||
);
|
||||
} else {
|
||||
throw new Error('Mirror URL is not a valid');
|
||||
}
|
||||
}
|
||||
return this.nodeInfo.mirrorURL;
|
||||
} else {
|
||||
return 'https://nodejs.org/download/v8-canary';
|
||||
}
|
||||
|
|
17
src/main.ts
17
src/main.ts
|
@ -7,7 +7,11 @@ import * as path from 'path';
|
|||
import {restoreCache} from './cache-restore';
|
||||
import {isCacheFeatureAvailable} from './cache-utils';
|
||||
import {getNodejsDistribution} from './distributions/installer-factory';
|
||||
import {getNodeVersionFromFile, printEnvDetailsAndSetOutput} from './util';
|
||||
import {
|
||||
getNodeVersionFromFile,
|
||||
printEnvDetailsAndSetOutput,
|
||||
validateMirrorURL
|
||||
} from './util';
|
||||
import {State} from './constants';
|
||||
|
||||
export async function run() {
|
||||
|
@ -33,12 +37,8 @@ export async function run() {
|
|||
arch = os.arch();
|
||||
}
|
||||
|
||||
const mirrorURL = core.getInput('mirror-url');
|
||||
if (mirrorURL === ' ' && mirrorURL === undefined) {
|
||||
core.error(
|
||||
'Mirror URL is emptry or undefined. The default mirror URL will be used.'
|
||||
);
|
||||
}
|
||||
const mirrorurl = core.getInput('mirror-url');
|
||||
const mirrorURL = validateMirrorURL(mirrorurl);
|
||||
|
||||
if (version) {
|
||||
const token = core.getInput('token');
|
||||
|
@ -121,6 +121,3 @@ function resolveVersionInput(): string {
|
|||
|
||||
return version;
|
||||
}
|
||||
export function setupNodeJs(mirrorURL: string) {
|
||||
throw new Error('Function not implemented.');
|
||||
}
|
||||
|
|
|
@ -97,7 +97,13 @@ async function getToolVersion(tool: string, options: string[]) {
|
|||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
export function validateMirrorURL(mirrorURL) {
|
||||
if (mirrorURL === ' ' || mirrorURL.trim() === 'undefined') {
|
||||
throw new Error('Mirror URL is empty. Please provide a valid mirror URL.');
|
||||
} else {
|
||||
return mirrorURL;
|
||||
}
|
||||
}
|
||||
export const unique = () => {
|
||||
const encountered = new Set();
|
||||
return (value: unknown): boolean => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue