mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Install Bundler at runtime if not already part of the stdlib
* This gives more flexibility to choose the Bundler version.
This commit is contained in:
+12
-5
@@ -960,6 +960,7 @@ const os = __webpack_require__(87)
|
||||
const fs = __webpack_require__(747)
|
||||
const path = __webpack_require__(622)
|
||||
const core = __webpack_require__(470)
|
||||
const exec = __webpack_require__(986)
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
@@ -981,6 +982,9 @@ async function run() {
|
||||
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
|
||||
|
||||
setupPath(ruby, newPathEntries)
|
||||
|
||||
await installBundler(platform, rubyPrefix)
|
||||
|
||||
core.setOutput('ruby-prefix', rubyPrefix)
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
@@ -1065,6 +1069,14 @@ function setupPath(ruby, newPathEntries) {
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
}
|
||||
|
||||
async function installBundler(platform, rubyPrefix) {
|
||||
const bundle_exe = platform === 'windows-latest' ? 'bundle.cmd' : 'bundle'
|
||||
// Install Bundler if not already part of the stdlib
|
||||
if (!fs.existsSync(path.join(rubyPrefix, 'bin', bundle_exe))) {
|
||||
await exec.exec(path.join(rubyPrefix, 'bin', 'gem'), ['install', 'bundler', '-v', '~> 1', '--no-document'])
|
||||
}
|
||||
}
|
||||
|
||||
function getVirtualEnvironmentName() {
|
||||
const platform = os.platform()
|
||||
if (platform === 'linux') {
|
||||
@@ -4858,11 +4870,6 @@ async function install(platform, ruby) {
|
||||
await setupMSWin() : await setupMingw(version)
|
||||
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
|
||||
|
||||
// Install Bundler if needed
|
||||
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
|
||||
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
|
||||
}
|
||||
|
||||
return [rubyPrefix, newPathEntries]
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ const os = require('os')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const core = require('@actions/core')
|
||||
const exec = require('@actions/exec')
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
@@ -23,6 +24,9 @@ export async function run() {
|
||||
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
|
||||
|
||||
setupPath(ruby, newPathEntries)
|
||||
|
||||
await installBundler(platform, rubyPrefix)
|
||||
|
||||
core.setOutput('ruby-prefix', rubyPrefix)
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
@@ -107,6 +111,14 @@ function setupPath(ruby, newPathEntries) {
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
}
|
||||
|
||||
async function installBundler(platform, rubyPrefix) {
|
||||
const bundle_exe = platform === 'windows-latest' ? 'bundle.cmd' : 'bundle'
|
||||
// Install Bundler if not already part of the stdlib
|
||||
if (!fs.existsSync(path.join(rubyPrefix, 'bin', bundle_exe))) {
|
||||
await exec.exec(path.join(rubyPrefix, 'bin', 'gem'), ['install', 'bundler', '-v', '~> 1', '--no-document'])
|
||||
}
|
||||
}
|
||||
|
||||
function getVirtualEnvironmentName() {
|
||||
const platform = os.platform()
|
||||
if (platform === 'linux') {
|
||||
|
||||
@@ -50,11 +50,6 @@ export async function install(platform, ruby) {
|
||||
await setupMSWin() : await setupMingw(version)
|
||||
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
|
||||
|
||||
// Install Bundler if needed
|
||||
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
|
||||
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
|
||||
}
|
||||
|
||||
return [rubyPrefix, newPathEntries]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user