mirror of
https://github.com/Minionguyjpro/Inno-Setup-Action
synced 2026-02-18 09:31:19 +01:00
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
const core = require("@actions/core");
|
|
const fs = require("fs").promises;
|
|
const { execFile } = require("child_process");
|
|
|
|
const workspacePath = process.env.GITHUB_WORKSPACE;
|
|
const options = core.getMultilineInput("options");
|
|
const path = core.getInput("path");
|
|
|
|
let repoError;
|
|
let platformError;
|
|
|
|
async function run() {
|
|
try {
|
|
if (process.platform === "win32") {
|
|
let workspaceExists;
|
|
try {
|
|
await fs.access(workspacePath);
|
|
workspaceExists = true;
|
|
} catch {
|
|
workspaceExists = false;
|
|
}
|
|
|
|
const workspaceNotEmpty = (await fs.readdir(workspacePath)).length > 0;
|
|
|
|
if (workspaceExists && workspaceNotEmpty) {
|
|
const escapedOptions = options.map((str) =>
|
|
str.replace(/(["'])/g, "$1"),
|
|
);
|
|
|
|
execFile(
|
|
`${process.env["ProgramFiles(x86)"]}\\Inno Setup 6\\iscc.exe`,
|
|
[...escapedOptions, `${workspacePath}\\${path}`],
|
|
(execError, stdout, stderr) => {
|
|
console.log(stdout, stderr);
|
|
if (execError) {
|
|
core.setFailed(`Execution failed with error: ${stderr}`);
|
|
process.exit(execError.code || 1);
|
|
}
|
|
},
|
|
);
|
|
} else {
|
|
throw new Error(
|
|
"The repository was not cloned. Please specify the actions/checkout action before this step.",
|
|
);
|
|
}
|
|
} else {
|
|
throw new Error("This action is only supported on Windows!");
|
|
}
|
|
} catch (error) {
|
|
core.setFailed(error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
run();
|