From 58c83414848011c0aab70ca8ed6d3fe3183e5b6f Mon Sep 17 00:00:00 2001 From: 20x-dz <113644268+20x-dz@users.noreply.github.com> Date: Thu, 22 Jun 2023 10:36:49 +0200 Subject: [PATCH] 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. --- index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index c87cad6..ae8f382 100644 --- a/index.js +++ b/index.js @@ -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}`