Skip to content

Commit

Permalink
Install Bundler at runtime if not already part of the stdlib
Browse files Browse the repository at this point in the history
* This gives more flexibility to choose the Bundler version.
  • Loading branch information
eregon committed Mar 31, 2020
1 parent 1e2e6e1 commit 11238a2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
17 changes: 12 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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') {
Expand Down
5 changes: 0 additions & 5 deletions windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down

0 comments on commit 11238a2

Please sign in to comment.