mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Tweak rubygems input behavior
When a fixed version is passed, it should be the minimum RubyGems version for the whole matrix, i.e., RubyGems should not be dowgraded past the default version of the oldest Ruby in the matrix.
This commit is contained in:
committed by
Benoit Daloze
parent
578365d08b
commit
8781aa98b4
+21
-2
@@ -58965,12 +58965,31 @@ __nccwpck_require__.r(__webpack_exports__);
|
||||
/* harmony export */ });
|
||||
const path = __nccwpck_require__(5622)
|
||||
const exec = __nccwpck_require__(1514)
|
||||
const semver = __nccwpck_require__(5911)
|
||||
|
||||
async function rubygemsUpdate(rubygemsVersionInput, rubyPrefix) {
|
||||
const gem = path.join(rubyPrefix, 'bin', 'gem')
|
||||
const rubygemsVersion = (rubygemsVersionInput === 'latest') ? [] : [rubygemsVersionInput]
|
||||
|
||||
await exec.exec(gem, ['update', '--system', ...rubygemsVersion])
|
||||
let gemVersion = ''
|
||||
|
||||
await exec.exec(gem, ['--version'], {
|
||||
listeners: {
|
||||
stdout: (data) => (gemVersion += data.toString()),
|
||||
}
|
||||
});
|
||||
|
||||
gemVersion = semver.coerce(gemVersion.trim())
|
||||
console.log(`Default RubyGems version is ${gemVersion}`)
|
||||
|
||||
if (rubygemsVersionInput === 'latest') {
|
||||
console.log('Updating RubyGems to latest version')
|
||||
await exec.exec(gem, ['update', '--system'])
|
||||
} else if (semver.gt(rubygemsVersionInput, gemVersion)) {
|
||||
console.log(`Updating RubyGems to ${rubygemsVersionInput}`)
|
||||
await exec.exec(gem, ['update', '--system', rubygemsVersionInput])
|
||||
} else {
|
||||
console.log(`Skipping RubyGems update because the given version (${rubygemsVersionInput}) is not newer than the default version (${gemVersion})`)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user