diff --git a/lib/getInstances.js b/lib/getInstances.js new file mode 100644 index 00000000..5e1d9449 --- /dev/null +++ b/lib/getInstances.js @@ -0,0 +1,14 @@ +const fileOps = require("./fileOps.js"); + +module.exports = { + sync: function(){ + let instances; + try { + instances = fileOps.getDirectoriesSync("./instances/"); + } catch (e) { + // there are no instances created yet, probably missing the folder + instances = []; + } + return instances; + } +} \ No newline at end of file diff --git a/lib/manager/modManager.js b/lib/manager/modManager.js index e7666e38..0cdcc769 100644 --- a/lib/manager/modManager.js +++ b/lib/manager/modManager.js @@ -11,7 +11,7 @@ const factorioAPI = require("node-factorio-api"); const fileOps = require("./../fileOps.js"); const config = require("./../../config"); -const instances = fileOps.getDirectoriesSync("./instances/"); +const instances = require("./../getInstances.js").sync(); /** Lists mods for an instance as a table. Warning, handles printing internally. @param {string} instance - Name of the instance or "shared" @@ -130,3 +130,12 @@ module.exports.downloadFromGitURL = function(url){ }); } } +/* +module.exports.findUpdates = function(){ + console.log("Downloading mods..."); + // get JSON data about releases + let res = syncRequest('GET', 'https://api.github.com/repos/Danielv123/factorioClusterioMod/releases', {"headers":{"User-Agent":"Fuck you for requiring user agents!"}}); + let url = JSON.parse(res.getBody())[0].assets[0].browser_download_url; + let name = JSON.parse(res.getBody())[0].assets[0].name; + console.log(JSON.parse(res.getBody())) +}*/ \ No newline at end of file diff --git a/lib/modManager.js b/lib/modManager.js deleted file mode 100644 index b17763fa..00000000 --- a/lib/modManager.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports.findUpdates = function(){ - console.log("Downloading mods..."); - // get JSON data about releases - let res = syncRequest('GET', 'https://api.github.com/repos/Danielv123/factorioClusterioMod/releases', {"headers":{"User-Agent":"Fuck you for requiring user agents!"}}); - let url = JSON.parse(res.getBody())[0].assets[0].browser_download_url; - let name = JSON.parse(res.getBody())[0].assets[0].name; - console.log(JSON.parse(res.getBody())) -} \ No newline at end of file