fix: check if options were passed as arguments (#68)

before needlessly printing an error in the console, as an empty string
is an invalid JSON string.
This commit is contained in:
20x-dz 2023-06-22 10:36:49 +02:00 committed by GitHub
parent 363bb1be96
commit 58c8341484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -110,12 +110,15 @@ async function dep() {
let verbosity = core.getInput('verbosity') let verbosity = core.getInput('verbosity')
let options = [] let options = []
try { try {
for (let [key, value] in Object.entries(JSON.parse(core.getInput('options')))) { let optionsArg = core.getInput('options')
if (optionsArg !== '') {
for (let [key, value] in Object.entries(JSON.parse(optionsArg))) {
options.push('-o', `${key}=${value}`) options.push('-o', `${key}=${value}`)
} }
} catch (e) { } catch (e) {
console.error('Invalid JSON in options') console.error('Invalid JSON in options')
} }
}
try { try {
await $`php ${dep} ${cmd} --no-interaction ${ansi} ${verbosity} ${options}` await $`php ${dep} ${cmd} --no-interaction ${ansi} ${verbosity} ${options}`