diff --git a/main.js b/main.js index 0b7a7fb..0a41705 100644 --- a/main.js +++ b/main.js @@ -13,12 +13,7 @@ var modList = mods.mod_list; var modDownloads = mods.mod_downloads; modList.forEach((ele, idx, arr) => { - if (process.argv[2] != "overwrite"){ - if (Object.keys(oldRegistry).includes(ele)) { - return; - } - } - + let link = modDownloads[ele]; let modinfo = { modName: "", @@ -26,22 +21,25 @@ modList.forEach((ele, idx, arr) => { } + modinfo.modName = "*" + ele; + registry[ele] = modinfo; + if (link == "client"){ modinfo.modName = "*" + ele; return; } - let output = cp.execSync("cd /root/mcserver/mods && wget --content-disposition -nc " + link).toString('utf-8'); //change dir and download mod - console.log(output); - try { - modinfo.modName = output.match(/(["'])(?:(?=(\\?))\2.)*?\1/)[0];//kill myself? - modinfo.modName = modinfo.modName.substring(1, modinfo.modName.length - 1); - } catch{ - modinfo.modName = "*" + ele; + + if (process.argv[2] != "overwrite"){ + if (Object.keys(oldRegistry).includes(ele.substring(1))) { + return; + } } - console.log("\n\n\n\n\n\n" + modinfo.modName + "\n\n\n\n\n\n"); - registry[ele] = modinfo; + let output = cp.execSync("cd /root/mcserver/mods && wget --content-disposition -nc " + link).toString('utf-8'); //change dir and download mod + console.log(output); + console.log("\n\n\n\n\n\n" + modinfo.modName + "\n\n\n\n\n\n"); + }); fs.writeFileSync("/root/mcserver/modRegistry.yaml", yaml.stringify(registry));