From f0c02fb2a5b3b69bb91004dd49d409eb6adfe7cd Mon Sep 17 00:00:00 2001 From: Dragan Filipovic Date: Tue, 21 Feb 2023 17:10:24 +0100 Subject: [PATCH] fix: #118 check undefined default values --- src/inputs.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/inputs.js b/src/inputs.js index 2c10046..06c8d60 100644 --- a/src/inputs.js +++ b/src/inputs.js @@ -10,7 +10,11 @@ const githubWorkspace = process.env.GITHUB_WORKSPACE; const remoteUser = process.env.REMOTE_USER || process.env.INPUT_REMOTE_USER; const defaultInputs = { + source: '', target: `/home/${remoteUser}/`, + exclude: '', + args: '-rlgoDzvc -i', + sshCmdArgs: '-o StrictHostKeyChecking=no', deployKeyName: `deploy_key_${remoteUser}_${Date.now()}` }; @@ -21,18 +25,19 @@ const inputs = { inputNames.forEach((input) => { const inputName = snakeToCamel(input.toLowerCase()); const inputVal = process.env[input] || process.env[`INPUT_${input}`] || defaultInputs[inputName]; - let extendedVal = inputVal; + const validVal = inputVal === undefined ? defaultInputs[inputName] : inputVal; + let extendedVal = validVal; // eslint-disable-next-line default-case switch (inputName) { case 'source': - extendedVal = inputVal.split(' ').map((src) => `${githubWorkspace}/${src}`); + extendedVal = validVal.split(' ').map((src) => `${githubWorkspace}/${src}`); break; case 'args': - extendedVal = inputVal.split(' '); + extendedVal = validVal.split(' '); break; case 'exclude': case 'sshCmdArgs': - extendedVal = inputVal.split(',').map((item) => item.trim()); + extendedVal = validVal.split(',').map((item) => item.trim()); break; }