From ade4f1d5676f98d7d890c87e6151f47340ac235c Mon Sep 17 00:00:00 2001 From: Bryan Paxton <39971740+starbelly@users.noreply.github.com> Date: Tue, 20 Jul 2021 14:08:24 -0500 Subject: [PATCH] Don't preprend v when elixir version does not start with digits (#61) --- .github/workflows/ubuntu.yml | 3 +++ __tests__/setup-beam.test.js | 8 ++++++++ dist/index.js | 5 ++++- src/setup-beam.js | 5 ++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 837071ed..a535a487 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -103,6 +103,9 @@ jobs: - elixir-version: '1.10.3' otp-version: '22.3.4.1' os: 'ubuntu-20.04' + - elixir-version: 'master' + otp-version: '23.1' + os: 'ubuntu-20.04' steps: - uses: actions/checkout@v2 - name: Use erlef/setup-beam diff --git a/__tests__/setup-beam.test.js b/__tests__/setup-beam.test.js index 7dfca904..f1e71ff1 100644 --- a/__tests__/setup-beam.test.js +++ b/__tests__/setup-beam.test.js @@ -187,6 +187,14 @@ async function testElixirVersions() { got = await setupBeam.getElixirVersion(spec, otpVersion) assert.deepStrictEqual(got, expected) simulateInput('version-type', 'loose') + + simulateInput('version-type', 'strict') + spec = 'master' + otpVersion = '23.1' + expected = 'master-otp-23' + got = await setupBeam.getElixirVersion(spec, otpVersion) + assert.deepStrictEqual(got, expected) + simulateInput('version-type', 'loose') } async function testRebar3Versions() { diff --git a/dist/index.js b/dist/index.js index 3b76cec8..240106b5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4830,7 +4830,10 @@ async function getElixirVersion(exSpec0, otpVersion) { ) } - return `v${elixirVersionWithOTP}` + const DigitStart = new RegExp('^\\d+') + return DigitStart.test(elixirVersion) + ? `v${elixirVersionWithOTP}` + : elixirVersionWithOTP } async function getRebar3Version(r3Spec) { diff --git a/src/setup-beam.js b/src/setup-beam.js index 0dfee5fa..97a44d6e 100644 --- a/src/setup-beam.js +++ b/src/setup-beam.js @@ -174,7 +174,10 @@ async function getElixirVersion(exSpec0, otpVersion) { ) } - return `v${elixirVersionWithOTP}` + const DigitStart = new RegExp('^\\d+') + return DigitStart.test(elixirVersion) + ? `v${elixirVersionWithOTP}` + : elixirVersionWithOTP } async function getRebar3Version(r3Spec) {