mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-19 12:54:45 +00:00
unit tests
This commit is contained in:
parent
9a03ebd9cc
commit
fd1b409bc3
3 changed files with 43 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue