From 76ab357cbcc01b61d6fabeeb6cf3fb100664e59a Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Fri, 11 Nov 2022 09:10:22 +0100 Subject: [PATCH] Request during review changes --- src/installer.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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)