fixing the functions that ensure that the lines of the files are valid
authoranthony <astalarico@gmail.com>
Fri, 15 Jun 2018 05:45:25 +0000 (01:45 -0400)
committeranthony <astalarico@gmail.com>
Fri, 15 Jun 2018 05:45:25 +0000 (01:45 -0400)
and that they match the modules properties

setup/moduleLib.js

index 3c267de..de66f48 100644 (file)
@@ -14,24 +14,46 @@ const modLib = (function() {
             });
         },
         checkLine: function(line, mod){
-            for (var i = 0; i < acceptedToken.length; i++) {
-                if (line.startsWith(acceptedToken[i]) && (line.indexOf(`${mod.name}"`) > -1 || line.indexOf(`${mod.name}.php`) > -1) ){
-                    console.log(line)
-                    break;
-                }
-              }
+            if ( modLib.moduleFound(line, mod)){
+                console.log(line)
+            }
         },
         editFile: function(reader,mod){
             reader.on("line",function(line){
                 modLib.checkLine(line, mod)
             })
         },
-
+        moduleFound(line,mod){
+            if(modLib.isValidLine(line, mod) ){
+                if(line.indexOf(`${mod.name}"`) > -1 || line.indexOf(`${mod.name}.php`) > -1){
+                    return true;
+                } else {
+                    return false;
+                }
+            }
+        },
+        deactivateModule(mod, line){
+            
+        },
+        isValidLine(line){
+            let valid = false;
+            for (var i = 0; i < acceptedToken.length; i++) {
+                if(line.startsWith(acceptedToken[i]) ){
+                    valid = true;
+                    break;
+                } else{ 
+                    valid = false;
+                }
+            }
+            return valid;
+        },
         setModules: function(modType,modName){
             appState[modType] = modName;
             return appState;
         },
-
+        moduleActive(mod){
+            return mod.active;
+        },
         storeModules: function(appState){
             localStorage.setItem("app", JSON.stringify(appState));
         },