moved functions out the main function
improves readebility
This commit is contained in:
@ -1,16 +1,17 @@
|
||||
let mods_lock;
|
||||
function main() {
|
||||
const { http, https } = require('follow-redirects');
|
||||
const fs = require("fs");
|
||||
let downloadStarted = false;
|
||||
let dep = new Map();
|
||||
function main() {
|
||||
mods_lock = new Map(Object.entries(mods_lock));
|
||||
if(global.config.mods.curse.length === 0) globCallback("curse", {});
|
||||
global.config.mods.curse.forEach(mod => {
|
||||
getData(`search?categoryId=0&gameId=432&gameVersion=${encodeURI(global.config.gameVersion)}&index=0&pageSize=1&searchFilter=${encodeURI(mod)}§ionId=6&sort=0`, (result) => { // resolve projectID
|
||||
getData(`search?categoryId=0&gameId=432&gameVersion=${encodeURI(global.config.gameVersion)}&index=0&pageSize=15&searchFilter=${encodeURI(mod)}§ionId=6&sort=0`, (result) => { // resolve projectID
|
||||
resolveDep(result[0].id, downloadMods);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var resolveDepRecursionCount = 0;
|
||||
function resolveDep(modId, callback) {
|
||||
@ -25,7 +26,7 @@ function main() {
|
||||
}
|
||||
dep.set(String(modId), {fileId: rightVersion.id, url: rightVersion.downloadUrl, filename: rightVersion.fileName});
|
||||
rightVersion.dependencies.forEach(mod => {
|
||||
if(mod.type !== 3) return
|
||||
if(mod.type !== 3) return;
|
||||
resolveDep(mod.addonId, callback);
|
||||
});
|
||||
--resolveDepRecursionCount;
|
||||
@ -107,7 +108,7 @@ function main() {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function(mods_lock_p, callback) {
|
||||
mods_lock = mods_lock_p;
|
||||
globCallback = callback;
|
||||
|
||||
Reference in New Issue
Block a user