From 8e98e53eb631eefa96ea49bf1eb14a822c2473b9 Mon Sep 17 00:00:00 2001 From: Minionguyjpro Date: Mon, 11 Dec 2023 16:17:53 +0100 Subject: [PATCH] Update index.js --- dist/index.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/dist/index.js b/dist/index.js index f60305a..606dcb5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,28 +1,23 @@ const fs = require('fs'); const core = require('@actions/core'); -// eslint-disable-next-line no-unused-vars -const github = require('@actions/github'); const workspacePath = process.env.GITHUB_WORKSPACE; const options = core.getInput('options'); const path = core.getInput('path'); -var exec = require('child_process').exec; - if (process.platform === 'win32') { - if (fs.existsSync(process.env.GITHUB_WORKSPACE) && fs.readdirSync(workspacePath).length > 0) { - exec(`"%PROGRAMFILES(X86)%\\Inno Setup 6\\iscc.exe" ${options} "${workspacePath}\\${path}"`, { stdio: 'ignore' }, function (error, stdout, stderr) { - console.log(stdout); - if (error) { - core.error(stderr); - exit(1); + try { + if (fs.existsSync(workspacePath) && fs.readdirSync(workspacePath).length > 0) { + const { stderr } = require('child_process').execSync(`"%PROGRAMFILES(X86)%\\Inno Setup 6\\iscc.exe" ${options} "${workspacePath}\\${path}"`, { stdio: 'inherit' }); + if (stderr) { + throw new Error(stderr); } - }); - } else { - core.error('Error: The repository was not cloned. Please specify the actions/checkout action before this step.'); - exit(1); + } else { + throw new Error('The repository was not cloned. Please specify the actions/checkout action before this step.'); + } + } catch (error) { + core.setFailed(error.message); } } else { - core.error('Error: This action is only supported on Windows!'); - exit(1); + core.setFailed('This action is only supported on Windows!'); }