From a219c84d0f2df5c46c7e73cdc54825411ccd8644 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Wed, 13 Jun 2018 12:42:03 -0400 Subject: [PATCH] cleaning up unused variables and simplifying functions --- setup/moduleLib.js | 31 ++++++++++++++++++++++++++----- setup/renderer.js | 16 +--------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/setup/moduleLib.js b/setup/moduleLib.js index b39a4ac..641ea4e 100644 --- a/setup/moduleLib.js +++ b/setup/moduleLib.js @@ -1,24 +1,41 @@ const modLib = (function() { + let appState = {}; + let fs = require('fs'); + let path = require('path'); + let reader = require('readline'); + return { - + + createFileStream: function(filePath){ + return reader.createInterface({ + input: fs.createReadStream(filePath) + }); + }, + editFile: function(reader,mod){ reader.on("line",function(line){ + console.log(line) }) }, + setModules: function(modType,modName){ appState[modType] = modName; return appState; }, + storeModules: function(appState){ localStorage.setItem("app", JSON.stringify(appState)); }, + getModuleTypes: function(modules){ return Object.keys(modules) }, + getModules: function(){ return JSON.parse(localStorage.getItem("app")); }, + updateModule: function(appState){ let allMods = modLib.getModules(); allMods[appState.modType].forEach(function(mod, index){ @@ -28,6 +45,7 @@ const modLib = (function() { }) localStorage.setItem("app", JSON.stringify(allMods)); }, + getModuleByName: function(modName){ let mods = JSON.parse(localStorage.getItem("app")), newMods = []; for(modType in mods){ @@ -43,12 +61,14 @@ const modLib = (function() { let appState = JSON.parse(localStorage.getItem("app")); return appState[moduleType]; }, + getDevDirs: function(){ - let fullPath = path.join(__dirname, `../dev`); + let fullPath = require('path').join(__dirname, `../dev`); fs.readdir(fullPath, function(err, item) { - console.log(item) + }); }, + generateListItems: function(modType){ $(`

${modType}

`).appendTo( $("#module-list-container")); $(`