diff --git a/.gitignore b/.gitignore index 3eea59c..dea9f6a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,5 @@ node_modules/ .env .env.test -# Ide +# IDE .idea diff --git a/dist/index.js b/dist/index.js index 960d498..31f8a02 100755 --- a/dist/index.js +++ b/dist/index.js @@ -623,7 +623,7 @@ const sshDeploy = (() => { })(); const run = () => { - validateInputs([SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER]); + validateInputs({ SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER }); sshDeploy.init({ src: `${GITHUB_WORKSPACE}/${SOURCE}` || '', @@ -663,7 +663,7 @@ const validateRsync = (callback = () => {}) => { 'sudo apt-get --no-install-recommends install rsync', (err, data, stderr) => { if (err) { - console.log('⚠️ [CLI] Rsync installation failed ', err.message); + console.log('⚠️ [CLI] Rsync installation failed. Aborting ... ', err.message); process.abort(); } else { console.log('✅ [CLI] Rsync installed. \n', data, stderr); @@ -677,15 +677,19 @@ const validateRsync = (callback = () => {}) => { }; const validateInputs = (inputs) => { - const validInputs = inputs.filter((input) => { - if (!input) { - console.error(`⚠️ ${input} is mandatory`); + const inputKeys = Object.keys(inputs); + const validInputs = inputKeys.filter((inputKey) => { + const inputValue = inputs[inputKey]; + + if (!inputValue) { + console.error(`⚠️ [INPUTS] ${inputKey} is mandatory`); } - return input; + return inputValue; }); - if (validInputs.length !== inputs.length) { + if (validInputs.length !== inputKeys.length) { + console.error(`⚠️ [INPUTS] Inputs not valid, aborting ...`); process.abort(); } }; diff --git a/package.json b/package.json index a7a9cac..718a549 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ }, "scripts": { "build": "npm run lint && ncc build ./src/index.js -o dist", - "lint": "eslint ./src/index.js" + "lint": "eslint ./src/index.js", + "lint:fix": "eslint ./src/index.js --fix" }, "repository": { "type": "git", diff --git a/src/index.js b/src/index.js index 6ecb5ff..f0913fe 100644 --- a/src/index.js +++ b/src/index.js @@ -59,7 +59,7 @@ const sshDeploy = (() => { })(); const run = () => { - validateInputs([SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER]); + validateInputs({ SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER }); sshDeploy.init({ src: `${GITHUB_WORKSPACE}/${SOURCE}` || '', diff --git a/src/rsyncCli.js b/src/rsyncCli.js index da171f0..781a2c4 100644 --- a/src/rsyncCli.js +++ b/src/rsyncCli.js @@ -9,7 +9,7 @@ const validateRsync = (callback = () => {}) => { 'sudo apt-get --no-install-recommends install rsync', (err, data, stderr) => { if (err) { - console.log('⚠️ [CLI] Rsync installation failed ', err.message); + console.log('⚠️ [CLI] Rsync installation failed. Aborting ... ', err.message); process.abort(); } else { console.log('✅ [CLI] Rsync installed. \n', data, stderr); @@ -23,15 +23,19 @@ const validateRsync = (callback = () => {}) => { }; const validateInputs = (inputs) => { - const validInputs = inputs.filter((input) => { - if (!input) { - console.error(`⚠️ ${input} is mandatory`); + const inputKeys = Object.keys(inputs); + const validInputs = inputKeys.filter((inputKey) => { + const inputValue = inputs[inputKey]; + + if (!inputValue) { + console.error(`⚠️ [INPUTS] ${inputKey} is mandatory`); } - return input; + return inputValue; }); - if (validInputs.length !== inputs.length) { + if (validInputs.length !== inputKeys.length) { + console.error(`⚠️ [INPUTS] Inputs not valid, aborting ...`); process.abort(); } };