'node client.js manage shared list' now lists shared mods

This commit is contained in:
Danielv123 committed 2017-11-04 20:07:25 +01:00
1 parent f507b503e9
commit c901275f38
3 files changed
+32 -1

No files matched your search

+26 -1
View File
@@ -1,3 +1,5 @@
const rightpad = require("right-pad");
const factorioAPI = require("node-factorio-api");
const fileOps = require("./../fileOps.js");
@@ -18,7 +20,30 @@ module.exports.listMods = function(instance){
});
});
} else {
console.log(instance)
// list shared mods in /sharedMods/
factorioAPI.init(false, 'sharedMods/', '', '0.15.37');
console.log("Authenticating to factorio.com...")
factorioAPI.authenticate({
username: 'Danielv123',
token: '53faebce0a608b1195f01dcfd95ee1',
require_ownership: false
}).then(() => {
factorioAPI.getInstalledMods().then(mods => {
let modNames = ["Name:"];
let modVersions = ["Version:"];
mods.forEach(mod=>{
modNames.push(mod.name);
modVersions.push(mod.version);
});
let longestName = modNames.reduce(function (a, b) { return a.length > b.length ? a : b; });
let longestVersion = modVersions.reduce(function (a, b) { return a.length > b.length ? a : b; });
console.log("| "+rightpad("Name:", longestName.length, " ")+" | "+rightpad("Version:", longestVersion.length, " ")+" |");
mods.forEach(mod => {
console.log("| "+rightpad(mod.name, longestName.length, " ")+" | "+rightpad(mod.version, longestVersion.length, " ")+" |");
});
});
});
}
// get JSON data about GH releases