1
0
mirror of https://github.com/Minionguyjpro/Inno-Setup-Action synced 2026-02-18 17:41:18 +01:00

Update index.js

This commit is contained in:
Minionguyjpro
2023-12-11 17:37:34 +01:00
committed by GitHub
parent d21a3b2c41
commit 016d9d2047

14
dist/index.js vendored
View File

@@ -1,31 +1,45 @@
// Importing necessary modules
const fs = require('fs'); const fs = require('fs');
const core = require('@actions/core'); const core = require('@actions/core');
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const github = require('@actions/github'); const github = require('@actions/github');
// Getting the path to the workspace from environment variables
const workspacePath = process.env.GITHUB_WORKSPACE; const workspacePath = process.env.GITHUB_WORKSPACE;
// Getting inputs from the workflow
const options = core.getInput('options'); const options = core.getInput('options');
const path = core.getInput('path'); const path = core.getInput('path');
// Importing the child_process module for executing shell commands
var exec = require('child_process').exec; var exec = require('child_process').exec;
// Initializing an error variable
let error; let error;
// Checking if the platform is Windows
if (process.platform === 'win32') { 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) { 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 (error, stdout, stderr) {
// Logging the standard output of the command
console.log(stdout); console.log(stdout);
// Handling errors, if any
if (error) { if (error) {
core.setFailed(stderr); core.setFailed(stderr);
process.exit(error.code || 1); process.exit(error.code || 1);
} }
}); });
} else { } else {
// Setting an error code and failing the workflow if the repository is not cloned
error = { code: 1 } error = { code: 1 }
core.setFailed('The repository was not cloned. Please specify the actions/checkout action before this step.'); core.setFailed('The repository was not cloned. Please specify the actions/checkout action before this step.');
process.exit(error.code); process.exit(error.code);
} }
} else { } else {
// Setting an error code and failing the workflow if the platform is not Windows
error = { code: 1 }; error = { code: 1 };
core.setFailed('This action is only supported on Windows!'); core.setFailed('This action is only supported on Windows!');
process.exit(error.code); process.exit(error.code);