From e75d08ca1053c444fbe4f31eeb10d8aa9ac55aee Mon Sep 17 00:00:00 2001
From: Benjamin Toby <benoti.san@gmail.com>
Date: Sun, 29 Oct 2023 13:26:29 +0100
Subject: [PATCH] Bugfix

---
 deploy/start.js | 12 +++++++++---
 package.json    |  2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/deploy/start.js b/deploy/start.js
index 8435523..4a217de 100755
--- a/deploy/start.js
+++ b/deploy/start.js
@@ -73,6 +73,10 @@ function startProcess({ command, preflight, redeploy_file, port, first_run }) {
                 try {
                     const runPreflight = preflightFn(preflight);
 
+                    if (!runPreflight) {
+                        // TODO: Action to take if preflight fails
+                    }
+
                     if (!preflight) {
                         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.`
@@ -164,16 +168,18 @@ function preflightFn(preflight) {
         if (typeof preflight == "string") {
             execFileSync(preflight, options);
         } else if (typeof preflight == "object" && preflight?.[0]) {
-            preflight.forEach((cmd, index) => {
+            for (let i = 0; i < preflight.length; i++) {
+                const cmd = preflight[i];
                 try {
                     const execCmd = execSync(cmd, options);
                 } catch (error) {
                     console.log(
                         `${colors.FgRed}Error:${colors.Reset} Preflight command ${cmd} Failed! => ${error.message}`
                     );
-                    process.exit();
+                    return false;
+                    break;
                 }
-            });
+            }
         }
         return true;
     } catch (error) {
diff --git a/package.json b/package.json
index 81c2ba1..cc62ef3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "nodecid",
-    "version": "1.0.2",
+    "version": "1.0.3",
     "description": "Simple CI/CD process",
     "main": "index.js",
     "bin": {