diff --git a/dist/index.js b/dist/index.js index cd46af1..0e5748b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9284,7 +9284,13 @@ async function getOTPVersion(otpSpec0, osVersion) { async function getElixirVersion(exSpec0, otpVersion0) { const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2] - const otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] + let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] + + const userSuppliedOtp = exSpec0.match(/-otp-(\d+)/)?.[1] ?? null + + if (userSuppliedOtp && isVersion(userSuppliedOtp)) { + otpVersionMajor = userSuppliedOtp + } const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions() const spec = exSpec0.replace(/-otp-.*$/, '') diff --git a/src/setup-beam.js b/src/setup-beam.js index c5ebb37..6e8f8f4 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -184,7 +184,13 @@ async function getOTPVersion(otpSpec0, osVersion) { async function getElixirVersion(exSpec0, otpVersion0) { const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2] - const otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] + let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] + + const userSuppliedOtp = exSpec0.match(/-otp-(\d+)/)?.[1] ?? null + + if (userSuppliedOtp && isVersion(userSuppliedOtp)) { + otpVersionMajor = userSuppliedOtp + } const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions() const spec = exSpec0.replace(/-otp-.*$/, '') diff --git a/test/setup-beam.test.js b/test/setup-beam.test.js index 0ded269..de2d6dc 100644 --- a/test/setup-beam.test.js +++ b/test/setup-beam.test.js @@ -511,6 +511,12 @@ describe('.getOTPVersion(_) - Elixir', () => { got = await setupBeam.getElixirVersion(spec, otpVersion) assert.deepStrictEqual(got, expected) + spec = '1.16.2-otp-26' + otpVersion = 'OTP-27' + expected = 'v1.16.2-otp-26' + got = await setupBeam.getElixirVersion(spec, otpVersion) + assert.deepStrictEqual(got, expected) + spec = '1.12.1' otpVersion = 'OTP-24.0.2' expected = 'v1.12.1-otp-24'