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:
David Rodríguez
2022-01-23 11:55:32 +01:00
committed by Benoit Daloze
parent 578365d08b
commit 8781aa98b4
5 changed files with 60 additions and 10 deletions
Generated Vendored
+21 -2
View File
@@ -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
}