From b74d35cf2b13a78f72bb2112e085c8ee66c0c9f3 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 4 May 2023 19:22:57 +0200 Subject: [PATCH] add test action, prevent failure on empty options --- .github/workflows/test.yml | 17 +++++++++++++++++ index.js | 14 +++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f61b4e3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,17 @@ +name: 'build-test' +on: # rebuild any PRs and main branch changes + pull_request: + push: + branches: + - master + - 'releases/*' + +jobs: + test: # make sure the action works on a clean machine without building + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./ + with: + dep: list + deployer-version: "7.3.0" diff --git a/index.js b/index.js index affece9..f39cc9d 100644 --- a/index.js +++ b/index.js @@ -109,12 +109,16 @@ async function dep() { let ansi = core.getBooleanInput('ansi') ? '--ansi' : '--no-ansi' 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 optionsInput = core.getInput('options'); + + if (optionsInput !== '') { + try { + for (let [key, value] in Object.entries(JSON.parse(optionsInput))) { + options.push('-o', `${key}=${value}`) + } + } catch (e) { + throw new Error('Invalid JSON in options') } - } catch (e) { - throw new Error('Invalid JSON in options') } try {