From 4784c278e69f039c63f2792123f802b1b4584018 Mon Sep 17 00:00:00 2001 From: Minionguyjpro Date: Tue, 2 Jan 2024 20:11:10 +0100 Subject: [PATCH] Update main.js --- src/main.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main.js b/src/main.js index 518f433..3680faf 100644 --- a/src/main.js +++ b/src/main.js @@ -12,33 +12,35 @@ const path = core.getInput('path') // Importing the child_process module for executing shell commands const exec = require('child_process').exec -// Initializing an error variable -let error; +// Initializing error variables +let repoError; +let platformError; // Checking if the platform is Windows if (process.platform === 'win32') { // Checking if the GitHub workspace exists and is not empty if (fs.existsSync(process.env.GITHUB_WORKSPACE) && fs.readdirSync(workspacePath).length > 0) { // Building and executing the Inno Setup compiler command - exec(`"%PROGRAMFILES(X86)%\\Inno Setup 6\\iscc.exe" ${options} "${workspacePath}\\${path}"`, { stdio: 'ignore' }, function (error, stdout, stderr) { + exec(`"%PROGRAMFILES(X86)%\\Inno Setup 6\\iscc.exe" ${options} "${workspacePath}\\${path}"`, { stdio: 'ignore' }, function (execError, stdout, stderr) { // Logging the standard output of the command console.log(stdout) // Handling errors, if any - if (error) { - core.setFailed(stderr) - process.exit(error.code || 1) + if (execError) { + repoError = { code: execError.code || 1 }; + core.setFailed(stderr); + process.exit(repoError.code); } }); } else { // Setting an error code and failing the workflow if the repository is not cloned - error = { code: 1 } + repoError = { code: 1 } core.setFailed('The repository was not cloned. Please specify the actions/checkout action before this step.'); - process.exit(error.code) + process.exit(repoError.code) } } else { // Setting an error code and failing the workflow if the platform is not Windows - error = { code: 1 }; + platformError = { code: 1 }; core.setFailed('This action is only supported on Windows!') - process.exit(error.code) + process.exit(platformError.code) }