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)