diff --git a/bundler.js b/bundler.js index 3b86b0fc2..03d960467 100644 --- a/bundler.js +++ b/bundler.js @@ -120,13 +120,14 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock } } - // Use Bundler 2.3 when we use Ruby 2.3.2-2.5 + const targetRubyVersion = common.targetRubyVersion(engine, rubyVersion) + // Use Bundler 2.3 when we use Ruby 2.3.2 - 2.5 // Use Bundler 2.4 when we use Ruby 2.6-2.7 if (bundlerVersion == '2') { - if (engine === 'ruby' && floatVersion <= 2.5) { - console.log('Ruby 2.3.2-2.5 only works with Bundler 2.3') + if (targetRubyVersion <= 2.5) { // < 2.3.2 already handled above + console.log('Ruby 2.3.2 - 2.5 only works with Bundler 2.3') bundlerVersion = '2.3' - } else if (engine === 'ruby' && floatVersion <= 2.7) { + } else if (targetRubyVersion <= 2.7) { console.log('Ruby 2.6-2.7 only works with Bundler 2.4') bundlerVersion = '2.4' } diff --git a/common.js b/common.js index c575f8c0d..531be0f65 100644 --- a/common.js +++ b/common.js @@ -95,6 +95,23 @@ export function isBundler2dot2Default(engine, rubyVersion) { } } +export function targetRubyVersion(engine, rubyVersion) { + const version = floatVersion(rubyVersion) + if (engine === 'ruby') { + return version + } else if (engine === 'jruby') { + if (version === 9.1) { + return 2.3 + } else if (version === 9.2) { + return 2.5 + } else if (version === 9.3) { + return 2.6 + } + } + + return 9.9 // unknown, assume recent +} + export function floatVersion(rubyVersion) { const match = rubyVersion.match(/^\d+\.\d+/) if (match) { diff --git a/dist/index.js b/dist/index.js index 45e5b0948..db3477288 100644 --- a/dist/index.js +++ b/dist/index.js @@ -135,13 +135,14 @@ async function installBundler(bundlerVersionInput, rubygemsInputSet, lockFile, p } } - // Use Bundler 2.3 when we use Ruby 2.3.2-2.5 + const targetRubyVersion = common.targetRubyVersion(engine, rubyVersion) + // Use Bundler 2.3 when we use Ruby 2.3.2 - 2.5 // Use Bundler 2.4 when we use Ruby 2.6-2.7 if (bundlerVersion == '2') { - if (engine === 'ruby' && floatVersion <= 2.5) { - console.log('Ruby 2.3.2-2.5 only works with Bundler 2.3') + if (targetRubyVersion <= 2.5) { // < 2.3.2 already handled above + console.log('Ruby 2.3.2 - 2.5 only works with Bundler 2.3') bundlerVersion = '2.3' - } else if (engine === 'ruby' && floatVersion <= 2.7) { + } else if (targetRubyVersion <= 2.7) { console.log('Ruby 2.6-2.7 only works with Bundler 2.4') bundlerVersion = '2.4' } @@ -285,6 +286,7 @@ __nccwpck_require__.r(__webpack_exports__); /* harmony export */ "isBundler1Default": () => (/* binding */ isBundler1Default), /* harmony export */ "isBundler2Default": () => (/* binding */ isBundler2Default), /* harmony export */ "isBundler2dot2Default": () => (/* binding */ isBundler2dot2Default), +/* harmony export */ "targetRubyVersion": () => (/* binding */ targetRubyVersion), /* harmony export */ "floatVersion": () => (/* binding */ floatVersion), /* harmony export */ "hashFile": () => (/* binding */ hashFile), /* harmony export */ "supportedPlatforms": () => (/* binding */ supportedPlatforms), @@ -392,6 +394,23 @@ function isBundler2dot2Default(engine, rubyVersion) { } } +function targetRubyVersion(engine, rubyVersion) { + const version = floatVersion(rubyVersion) + if (engine === 'ruby') { + return version + } else if (engine === 'jruby') { + if (version === 9.1) { + return 2.3 + } else if (version === 9.2) { + return 2.5 + } else if (version === 9.3) { + return 2.6 + } + } + + return 9.9 // unknown, assume recent +} + function floatVersion(rubyVersion) { const match = rubyVersion.match(/^\d+\.\d+/) if (match) {