From 0997e21bf3d0273e9e73c4bd6e02ee5f772ea8fa Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 27 Jul 2021 13:33:12 +0200 Subject: [PATCH] Fix check for TruffleRuby < 21.0 and Bundler 1 --- bundler.js | 4 ++-- common.js | 4 ++++ dist/index.js | 9 +++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bundler.js b/bundler.js index dfc3719..5b595e1 100644 --- a/bundler.js +++ b/bundler.js @@ -86,8 +86,8 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru // Avoid installing a newer Bundler version for head versions as it might not work. // For releases, even if they ship with Bundler 2 we install the latest Bundler. console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`) - } else if (engine === 'truffleruby' && !common.isHeadVersion(rubyVersion) && bundlerVersion.startsWith('1')) { - console.log(`Using Bundler 1 shipped with ${engine}`) + } else if (engine === 'truffleruby' && common.isBundler1Default(engine, rubyVersion) && bundlerVersion.startsWith('1')) { + console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`) } else { const gem = path.join(rubyPrefix, 'bin', 'gem') const bundlerVersionConstraint = bundlerVersion.match(/^\d+\.\d+\.\d+/) ? bundlerVersion : `~> ${bundlerVersion}` diff --git a/common.js b/common.js index 9153130..2d322b2 100644 --- a/common.js +++ b/common.js @@ -55,6 +55,10 @@ export function isStableVersion(rubyVersion) { return /^\d+(\.\d+)*$/.test(rubyVersion) } +export function isBundler1Default(engine, rubyVersion) { + return !isBundler2Default(engine, rubyVersion) +} + export function isBundler2Default(engine, rubyVersion) { if (engine === 'ruby') { return isHeadVersion(rubyVersion) || floatVersion(rubyVersion) >= 2.7 diff --git a/dist/index.js b/dist/index.js index 97e446d..58e3ed2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -100,8 +100,8 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi // Avoid installing a newer Bundler version for head versions as it might not work. // For releases, even if they ship with Bundler 2 we install the latest Bundler. console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`) - } else if (engine === 'truffleruby' && !common.isHeadVersion(rubyVersion) && bundlerVersion.startsWith('1')) { - console.log(`Using Bundler 1 shipped with ${engine}`) + } else if (engine === 'truffleruby' && common.isBundler1Default(engine, rubyVersion) && bundlerVersion.startsWith('1')) { + console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`) } else { const gem = path.join(rubyPrefix, 'bin', 'gem') const bundlerVersionConstraint = bundlerVersion.match(/^\d+\.\d+\.\d+/) ? bundlerVersion : `~> ${bundlerVersion}` @@ -229,6 +229,7 @@ __nccwpck_require__.r(__webpack_exports__); /* harmony export */ "measure": () => (/* binding */ measure), /* harmony export */ "isHeadVersion": () => (/* binding */ isHeadVersion), /* harmony export */ "isStableVersion": () => (/* binding */ isStableVersion), +/* harmony export */ "isBundler1Default": () => (/* binding */ isBundler1Default), /* harmony export */ "isBundler2Default": () => (/* binding */ isBundler2Default), /* harmony export */ "floatVersion": () => (/* binding */ floatVersion), /* harmony export */ "hashFile": () => (/* binding */ hashFile), @@ -296,6 +297,10 @@ function isStableVersion(rubyVersion) { return /^\d+(\.\d+)*$/.test(rubyVersion) } +function isBundler1Default(engine, rubyVersion) { + return !isBundler2Default(engine, rubyVersion) +} + function isBundler2Default(engine, rubyVersion) { if (engine === 'ruby') { return isHeadVersion(rubyVersion) || floatVersion(rubyVersion) >= 2.7