Refactor out config injection in modManager

Change config in modManager to be passed to each individual functions
instead of requiring it be present at load time.
This commit is contained in:
Hornwitser committed 2019-09-16 16:04:08 +02:00
1 parent 5f33cf4d3b
commit a783bd9651
3 files changed
+244 -240

No files matched your search

+5 -7
View File
@@ -21,6 +21,7 @@ const objectOps = require("lib/objectOps.js");
const fileOps = require("lib/fileOps");
const stringUtils = require("lib/stringUtils.js");
const pluginManager = require("lib/manager/pluginManager");
const modManager = require("lib/manager/modManager");
const hashFile = require('lib/hash').hashFile;
// Uhm...
@@ -245,18 +246,15 @@ async function manage(config, instance) {
if (instance !== undefined) {
if(tool == "mods"){
(async function(){try{
// do require down here to reduce master load time
const modManager = require("lib/manager/modManager.js")(config);
// allow managing mods
if(action == "list"){
console.log(await modManager.listMods(instance));
console.log(await modManager.listMods(config, instance));
} else if(action == "search"){
console.log(await modManager.findMods(process.argv[6]));
console.log(await modManager.findMods(config, process.argv[6]));
} else if(action == "add" || action == "download"){
await modManager.addMod(process.argv[6], instance);
await modManager.addMod(config, process.argv[6], instance);
} else if(action == "remove" || action == "rm" || action == "delete"){
await modManager.removeMod(process.argv[6], instance);
await modManager.removeMod(config, process.argv[6], instance);
} else {
usage(instance, tool);
}