Add ref: (version) support to .tool-versions parsing (#228)

f35f714 · Damir Vandic · 2023-08-15 13:05

3 files +6 -6
Message
{commit_body(@commit)}

Files changed

modified dist/index.js
+2 −2
@@ -10418,11 +10418,11 @@ function parseVersionFile(versionFilePath0) {
10418 10418 // If we ever start parsing something else, this should
10419 10419 // become default in a new option named e.g. version-file-type
10420 10420 versions.split('\n').forEach((line) => {
10421 const appVersion = line.match(/^([^ ]+)[ ]+([^ #]+)/)
10421 + const appVersion = line.match(/^([^ ]+)[ ]+(ref:v?)?([^ #]+)/)
10422 10422 if (appVersion) {
10423 10423 const app = appVersion[1]
10424 10424 if (['erlang', 'elixir', 'gleam', 'rebar'].includes(app)) {
10425 const [, , version] = appVersion
10425 + const [, , , version] = appVersion
10426 10426 core.info(`Consuming ${app} at version ${version}`)
10427 10427 appVersions.set(app, version)
10428 10428 }
modified src/setup-beam.js
+2 −2
@@ -602,11 +602,11 @@ function parseVersionFile(versionFilePath0) {
602 602 // If we ever start parsing something else, this should
603 603 // become default in a new option named e.g. version-file-type
604 604 versions.split('\n').forEach((line) => {
605 const appVersion = line.match(/^([^ ]+)[ ]+([^ #]+)/)
605 + const appVersion = line.match(/^([^ ]+)[ ]+(ref:v?)?([^ #]+)/)
606 606 if (appVersion) {
607 607 const app = appVersion[1]
608 608 if (['erlang', 'elixir', 'gleam', 'rebar'].includes(app)) {
609 const [, , version] = appVersion
609 + const [, , , version] = appVersion
610 610 core.info(`Consuming ${app} at version ${version}`)
611 611 appVersions.set(app, version)
612 612 }
modified test/setup-beam.test.js
+2 −2
@@ -511,8 +511,8 @@ async function testParseVersionFile() {
511 511 const gleam = '0.23.0'
512 512 const rebar3 = '3.16.0'
513 513 const toolVersions = `# a comment
514 erlang ${erlang}# comment, no space
515 elixir ${elixir} # comment, with space
514 +erlang ref:v${erlang}# comment, no space, and ref:v
515 +elixir ref:${elixir} # comment, with space and ref:
516 516 not-gleam 0.23 # not picked up
517 517 gleam ${gleam}
518 518 rebar ${rebar3}`

Parents: afb8586