Skip to content

Commit 3155eef

Browse files
override OTP version when specified in Elixir spec
1 parent cc72a5b commit 3155eef

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

dist/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9284,7 +9284,13 @@ async function getOTPVersion(otpSpec0, osVersion) {
92849284

92859285
async function getElixirVersion(exSpec0, otpVersion0) {
92869286
const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2]
9287-
const otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1]
9287+
let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1]
9288+
9289+
const userSuppliedOtp = exSpec0.match(/-otp-(\d+)/)?.[1] ?? null
9290+
9291+
if (userSuppliedOtp && isVersion(userSuppliedOtp)) {
9292+
otpVersionMajor = userSuppliedOtp
9293+
}
92889294

92899295
const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions()
92909296
const spec = exSpec0.replace(/-otp-.*$/, '')

src/setup-beam.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ async function getOTPVersion(otpSpec0, osVersion) {
184184

185185
async function getElixirVersion(exSpec0, otpVersion0) {
186186
const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2]
187-
const otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1]
187+
let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1]
188+
189+
const userSuppliedOtp = exSpec0.match(/-otp-(\d+)/)?.[1] ?? null
190+
191+
if (userSuppliedOtp && isVersion(userSuppliedOtp)) {
192+
otpVersionMajor = userSuppliedOtp
193+
}
188194

189195
const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions()
190196
const spec = exSpec0.replace(/-otp-.*$/, '')

test/setup-beam.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,12 @@ describe('.getOTPVersion(_) - Elixir', () => {
511511
got = await setupBeam.getElixirVersion(spec, otpVersion)
512512
assert.deepStrictEqual(got, expected)
513513

514+
spec = '1.16.2-otp-26'
515+
otpVersion = 'OTP-27'
516+
expected = 'v1.16.2-otp-26'
517+
got = await setupBeam.getElixirVersion(spec, otpVersion)
518+
assert.deepStrictEqual(got, expected)
519+
514520
spec = '1.12.1'
515521
otpVersion = 'OTP-24.0.2'
516522
expected = 'v1.12.1-otp-24'

0 commit comments

Comments
 (0)