diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index b57248757..d9302c4c4 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -1,17 +1,17 @@ +import * as cache from '@actions/cache'; import * as core from '@actions/core'; import * as exec from '@actions/exec'; import * as tc from '@actions/tool-cache'; -import * as cache from '@actions/cache'; import fs from 'fs'; -import path from 'path'; import osm from 'os'; +import path from 'path'; import each from 'jest-each'; +import OfficialBuilds from '../src/distributions/official_builds/official_builds'; import * as main from '../src/main'; import * as util from '../src/util'; -import OfficialBuilds from '../src/distributions/official_builds/official_builds'; describe('main tests', () => { let inputs = {} as any; @@ -95,6 +95,7 @@ describe('main tests', () => { ${'lts/erbium'} | ${'lts/erbium'} ${'lts/*'} | ${'lts/*'} ${'nodejs 12.3.4'} | ${'12.3.4'} + ${'nodejs lts-erbium'} | ${'lts/erbium'} ${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'} ${''} | ${''} ${'unknown format'} | ${'unknown format'} diff --git a/src/util.ts b/src/util.ts index 60f2649c2..6239164cf 100644 --- a/src/util.ts +++ b/src/util.ts @@ -14,7 +14,13 @@ export function parseNodeVersionFile(contents: string): string { if (!nodeVersion) { const found = contents.match(/^(?:nodejs\s+)?v?(?[^\s]+)$/m); - nodeVersion = found?.groups?.version; + + + if (found?.groups?.version?.includes('lts-')) { + nodeVersion = found?.groups?.version.replace(/-/g, '/'); + } else { + nodeVersion = found?.groups?.version; + } } // In the case of an unknown format,