fix: check if options were passed as arguments

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-21 22:40:25 +02:00
parent 363bb1be96
commit b698f123c0
No known key found for this signature in database
GPG key ID: F7091E0778711836

View file

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