mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-14 06:54:20 +02:00
Extract function to get the Ruby engine and version
This commit is contained in:
+16
-13
@@ -1794,19 +1794,7 @@ const axios = __webpack_require__(53)
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const rubyVersion = core.getInput('ruby-version')
|
||||
|
||||
let ruby = rubyVersion
|
||||
if (ruby.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
|
||||
ruby = 'ruby-' + ruby
|
||||
}
|
||||
if (!ruby.includes('-')) { // myruby -> myruby-stableVersion
|
||||
const versionsUrl = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata/versions.json'
|
||||
const response = await axios.get(versionsUrl)
|
||||
const stableVersions = response.data[ruby]
|
||||
const latestStableVersion = stableVersions[stableVersions.length-1]
|
||||
ruby = ruby + '-' + latestStableVersion
|
||||
}
|
||||
const ruby = await getRubyEngineAndVersion(core.getInput('ruby-version'))
|
||||
|
||||
const rubiesDir = `${process.env.HOME}/.rubies`
|
||||
await io.mkdirP(rubiesDir)
|
||||
@@ -1826,6 +1814,21 @@ async function run() {
|
||||
}
|
||||
}
|
||||
|
||||
async function getRubyEngineAndVersion(rubyVersion) {
|
||||
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
|
||||
return 'ruby-' + rubyVersion
|
||||
} else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion
|
||||
const engine = rubyVersion
|
||||
const versionsUrl = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata/versions.json'
|
||||
const response = await axios.get(versionsUrl)
|
||||
const stableVersions = response.data[engine]
|
||||
const latestStableVersion = stableVersions[stableVersions.length-1]
|
||||
return engine + '-' + latestStableVersion
|
||||
} else {
|
||||
return rubyVersion
|
||||
}
|
||||
}
|
||||
|
||||
function getVirtualEnvironmentName() {
|
||||
const platform = os.platform()
|
||||
if (platform == 'linux') {
|
||||
|
||||
Reference in New Issue
Block a user