This commit is contained in:
Benjamin Toby 2023-10-29 13:26:29 +01:00
parent 8816b0292b
commit e75d08ca10
2 changed files with 10 additions and 4 deletions

View File

@ -73,6 +73,10 @@ function startProcess({ command, preflight, redeploy_file, port, first_run }) {
try { try {
const runPreflight = preflightFn(preflight); const runPreflight = preflightFn(preflight);
if (!runPreflight) {
// TODO: Action to take if preflight fails
}
if (!preflight) { if (!preflight) {
console.log( console.log(
`${colors.FgRed}Error:${colors.Reset} No preflight included in config file. If you don't want to run any preflight command simply add an empty array.` `${colors.FgRed}Error:${colors.Reset} No preflight included in config file. If you don't want to run any preflight command simply add an empty array.`
@ -164,16 +168,18 @@ function preflightFn(preflight) {
if (typeof preflight == "string") { if (typeof preflight == "string") {
execFileSync(preflight, options); execFileSync(preflight, options);
} else if (typeof preflight == "object" && preflight?.[0]) { } else if (typeof preflight == "object" && preflight?.[0]) {
preflight.forEach((cmd, index) => { for (let i = 0; i < preflight.length; i++) {
const cmd = preflight[i];
try { try {
const execCmd = execSync(cmd, options); const execCmd = execSync(cmd, options);
} catch (error) { } catch (error) {
console.log( console.log(
`${colors.FgRed}Error:${colors.Reset} Preflight command ${cmd} Failed! => ${error.message}` `${colors.FgRed}Error:${colors.Reset} Preflight command ${cmd} Failed! => ${error.message}`
); );
process.exit(); return false;
break;
} }
}); }
} }
return true; return true;
} catch (error) { } catch (error) {

View File

@ -1,6 +1,6 @@
{ {
"name": "nodecid", "name": "nodecid",
"version": "1.0.2", "version": "1.0.3",
"description": "Simple CI/CD process", "description": "Simple CI/CD process",
"main": "index.js", "main": "index.js",
"bin": { "bin": {