unit tests

This commit is contained in:
panticmilos 2022-05-19 17:33:13 +02:00
parent 9a03ebd9cc
commit fd1b409bc3
3 changed files with 43 additions and 13 deletions

View file

@ -7,6 +7,7 @@ import * as tc from '@actions/tool-cache';
import * as path from 'path';
import * as semver from 'semver';
import fs = require('fs');
import * as installer from './installer';
//
// Node versions interface
@ -66,8 +67,8 @@ export async function getNode(
}
}
if(['current', 'latest', 'node'].includes(versionSpec)) {
versionSpec = await queryDistForMatch(versionSpec, arch);
if (isLatestSyntax(versionSpec)) {
versionSpec = await queryDistForMatch(versionSpec, arch);
core.info(`getting latest node version...`);
}
@ -376,13 +377,9 @@ async function queryDistForMatch(
}
let versions: string[] = [];
let nodeVersions = await getVersionsFromDist();
let nodeVersions = await installer.getVersionsFromDist();
if (
versionSpec === 'current' ||
versionSpec === 'latest' ||
versionSpec === 'node'
) {
if (isLatestSyntax(versionSpec)) {
core.info(`getting latest node version...`);
return nodeVersions[0].version;
}
@ -487,3 +484,7 @@ export function parseNodeVersionFile(contents: string): string {
}
return nodeVersion;
}
function isLatestSyntax(versionSpec): boolean {
return ['current', 'latest', 'node'].includes(versionSpec);
}