Skip to content

Commit 11238a2

Browse files
committed
Install Bundler at runtime if not already part of the stdlib
* This gives more flexibility to choose the Bundler version.
1 parent 1e2e6e1 commit 11238a2

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

dist/index.js

+12-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const os = require('os')
22
const fs = require('fs')
33
const path = require('path')
44
const core = require('@actions/core')
5+
const exec = require('@actions/exec')
56

67
export async function run() {
78
try {
@@ -23,6 +24,9 @@ export async function run() {
2324
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
2425

2526
setupPath(ruby, newPathEntries)
27+
28+
await installBundler(platform, rubyPrefix)
29+
2630
core.setOutput('ruby-prefix', rubyPrefix)
2731
} catch (error) {
2832
core.setFailed(error.message)
@@ -107,6 +111,14 @@ function setupPath(ruby, newPathEntries) {
107111
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
108112
}
109113

114+
async function installBundler(platform, rubyPrefix) {
115+
const bundle_exe = platform === 'windows-latest' ? 'bundle.cmd' : 'bundle'
116+
// Install Bundler if not already part of the stdlib
117+
if (!fs.existsSync(path.join(rubyPrefix, 'bin', bundle_exe))) {
118+
await exec.exec(path.join(rubyPrefix, 'bin', 'gem'), ['install', 'bundler', '-v', '~> 1', '--no-document'])
119+
}
120+
}
121+
110122
function getVirtualEnvironmentName() {
111123
const platform = os.platform()
112124
if (platform === 'linux') {

windows.js

-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ export async function install(platform, ruby) {
5050
await setupMSWin() : await setupMingw(version)
5151
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
5252

53-
// Install Bundler if needed
54-
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
55-
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
56-
}
57-
5853
return [rubyPrefix, newPathEntries]
5954
}
6055

0 commit comments

Comments
 (0)