From ef917a2f4acc844e8c473401e04e7dc245126ece Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Fri, 11 Nov 2022 09:10:22 +0100 Subject: [PATCH] Apply requested changes --- dist/setup/index.js | 9 ++------- src/installer.ts | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 15153a523..0886f2a19 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -73189,6 +73189,7 @@ const tc = __importStar(__nccwpck_require__(7784)); const path = __importStar(__nccwpck_require__(1017)); const semver = __importStar(__nccwpck_require__(5911)); const fs = __nccwpck_require__(7147); +const semver_1 = __nccwpck_require__(5911); const isVersionCanary = (versionSpec) => versionSpec.includes(`-v8-canary`); function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) { return __awaiter(this, void 0, void 0, function* () { @@ -73417,16 +73418,10 @@ function resolveVersionFromManifest(versionSpec, stable, auth, osArch = translat } }); } -// TODO - should we just export this from @actions/tool-cache? Lifted directly from there function evaluateVersions(versions, versionSpec) { let version = ''; core.debug(`evaluating ${versions.length} versions`); - versions = versions.sort((a, b) => { - if (semver.gt(a, b)) { - return 1; - } - return -1; - }); + versions = versions.sort(semver_1.compare); const matcher = isVersionCanary(versionSpec) ? evaluateCanaryMatcher(versionSpec) : potential => semver.satisfies(potential, versionSpec); diff --git a/src/installer.ts b/src/installer.ts index 675fd2b51..b324b09a3 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -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 {compare} from 'semver'; // // Node versions interface @@ -355,19 +356,13 @@ async function resolveVersionFromManifest( } } -// TODO - should we just export this from @actions/tool-cache? Lifted directly from there export function evaluateVersions( versions: string[], versionSpec: string ): string { let version = ''; core.debug(`evaluating ${versions.length} versions`); - versions = versions.sort((a, b) => { - if (semver.gt(a, b)) { - return 1; - } - return -1; - }); + versions = versions.sort(compare); const matcher: (potential: string) => boolean = isVersionCanary(versionSpec) ? evaluateCanaryMatcher(versionSpec)