mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 22:44:20 +02:00
Refactor how to call setup-ruby from other actions
* Automatically use inputs if available, use defaults otherwise.
This commit is contained in:
+9
-6
@@ -2199,20 +2199,23 @@ const inputDefaults = {
|
||||
'working-directory': '.',
|
||||
}
|
||||
|
||||
// entry point when this action is run on its own
|
||||
async function run() {
|
||||
try {
|
||||
const options = {}
|
||||
for (const key in inputDefaults) {
|
||||
options[key] = core.getInput(key)
|
||||
}
|
||||
await setupRuby(options)
|
||||
await setupRuby({})
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
// entry point when this action is run from other actions
|
||||
async function setupRuby(options) {
|
||||
const inputs = { ...inputDefaults, ...options }
|
||||
const inputs = { ...options }
|
||||
for (const key in inputDefaults) {
|
||||
if (!inputs.hasOwnProperty(key)) {
|
||||
inputs[key] = core.getInput(key) || inputDefaults[key]
|
||||
}
|
||||
}
|
||||
|
||||
process.chdir(inputs['working-directory'])
|
||||
|
||||
|
||||
@@ -13,20 +13,23 @@ const inputDefaults = {
|
||||
'working-directory': '.',
|
||||
}
|
||||
|
||||
// entry point when this action is run on its own
|
||||
export async function run() {
|
||||
try {
|
||||
const options = {}
|
||||
for (const key in inputDefaults) {
|
||||
options[key] = core.getInput(key)
|
||||
}
|
||||
await setupRuby(options)
|
||||
await setupRuby({})
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
// entry point when this action is run from other actions
|
||||
export async function setupRuby(options) {
|
||||
const inputs = { ...inputDefaults, ...options }
|
||||
const inputs = { ...options }
|
||||
for (const key in inputDefaults) {
|
||||
if (!inputs.hasOwnProperty(key)) {
|
||||
inputs[key] = core.getInput(key) || inputDefaults[key]
|
||||
}
|
||||
}
|
||||
|
||||
process.chdir(inputs['working-directory'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user