diff --git a/dist/index.js b/dist/index.js index d22e20a..c2c9e85 100644 --- a/dist/index.js +++ b/dist/index.js @@ -969,6 +969,7 @@ module.exports = require("os"); "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "run", function() { return run; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setupRuby", function() { return setupRuby; }); const os = __webpack_require__(87) const fs = __webpack_require__(747) const path = __webpack_require__(622) @@ -976,19 +977,31 @@ const core = __webpack_require__(470) const exec = __webpack_require__(986) const common = __webpack_require__(239) +const inputDefaults = { + 'ruby-version': 'default', + 'bundler': 'default', + 'working-directory': '.', +} + async function run() { try { - await main() + const options = {} + for (const key in inputDefaults) { + options[key] = core.getInput(key) + } + await setupRuby(options) } catch (error) { core.setFailed(error.message) } } -async function main() { - process.chdir(core.getInput('working-directory')) +async function setupRuby(options) { + const inputs = { ...inputDefaults, ...options } + + process.chdir(inputs['working-directory']) const platform = common.getVirtualEnvironmentName() - const [engine, parsedVersion] = parseRubyEngineAndVersion(core.getInput('ruby-version')) + const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version']) let installer if (platform === 'windows-latest' && engine !== 'jruby') { @@ -1006,9 +1019,9 @@ async function main() { setupPath(newPathEntries) - if (core.getInput('bundler') !== 'none') { + if (inputs['bundler'] !== 'none') { await common.measure('Installing Bundler', async () => - installBundler(platform, rubyPrefix, engine, version)) + installBundler(inputs['bundler'], platform, rubyPrefix, engine, version)) } core.setOutput('ruby-prefix', rubyPrefix) @@ -1113,8 +1126,8 @@ function readBundledWithFromGemfileLock() { return null } -async function installBundler(platform, rubyPrefix, engine, rubyVersion) { - var bundlerVersion = core.getInput('bundler') +async function installBundler(bundlerVersionInput, platform, rubyPrefix, engine, rubyVersion) { + var bundlerVersion = bundlerVersionInput if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') { bundlerVersion = readBundledWithFromGemfileLock() diff --git a/index.js b/index.js index 8e53081..61261ae 100644 --- a/index.js +++ b/index.js @@ -5,19 +5,31 @@ const core = require('@actions/core') const exec = require('@actions/exec') const common = require('./common') +const inputDefaults = { + 'ruby-version': 'default', + 'bundler': 'default', + 'working-directory': '.', +} + export async function run() { try { - await main() + const options = {} + for (const key in inputDefaults) { + options[key] = core.getInput(key) + } + await setupRuby(options) } catch (error) { core.setFailed(error.message) } } -async function main() { - process.chdir(core.getInput('working-directory')) +export async function setupRuby(options) { + const inputs = { ...inputDefaults, ...options } + + process.chdir(inputs['working-directory']) const platform = common.getVirtualEnvironmentName() - const [engine, parsedVersion] = parseRubyEngineAndVersion(core.getInput('ruby-version')) + const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version']) let installer if (platform === 'windows-latest' && engine !== 'jruby') { @@ -35,9 +47,9 @@ async function main() { setupPath(newPathEntries) - if (core.getInput('bundler') !== 'none') { + if (inputs['bundler'] !== 'none') { await common.measure('Installing Bundler', async () => - installBundler(platform, rubyPrefix, engine, version)) + installBundler(inputs['bundler'], platform, rubyPrefix, engine, version)) } core.setOutput('ruby-prefix', rubyPrefix) @@ -142,8 +154,8 @@ function readBundledWithFromGemfileLock() { return null } -async function installBundler(platform, rubyPrefix, engine, rubyVersion) { - var bundlerVersion = core.getInput('bundler') +async function installBundler(bundlerVersionInput, platform, rubyPrefix, engine, rubyVersion) { + var bundlerVersion = bundlerVersionInput if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') { bundlerVersion = readBundledWithFromGemfileLock()