mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 07:30:41 +09:00
#59 added node client.js manage mods shared/instance remove modname
This commit is contained in:
1 parent
5eaa94f4ac
commit
5d72832402
2 files changed
+25
-1
No files matched your search
@@ -146,6 +146,8 @@ if (!command || command == "help" || command == "--help") {
|
||||
modManager.findMods(process.argv[6]);
|
||||
} else if(action == "add" || action == "download"){
|
||||
modManager.addMod(process.argv[6], instance);
|
||||
} else if(action == "remove" || action == "rm" || action == "delete"){
|
||||
modManager.removeMod(process.argv[6], instance);
|
||||
} else if(action == "update"){
|
||||
modManager.updateAllMods();
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,8 @@ Provides tools to manage mods in a clusterio install
|
||||
const rightpad = require("right-pad");
|
||||
const asTable = require("as-table").configure({delimiter: ' | '});
|
||||
const moment = require("moment");
|
||||
const syncRequest = require("sync-request")
|
||||
const syncRequest = require("sync-request");
|
||||
const fs = require("fs");
|
||||
|
||||
const factorioAPI = require("node-factorio-api");
|
||||
const fileOps = require("./../fileOps.js");
|
||||
@@ -138,6 +139,27 @@ module.exports.addMod = function(term, instance){
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports.removeMod = function removeMod(term, instance, force = false){
|
||||
if(instance == "shared"){ // modDirectory has to end in /
|
||||
var modDirectory = "sharedMods/";
|
||||
} else {
|
||||
var modDirectory = "instances/"+instance+"/instanceMods/";
|
||||
}
|
||||
if(term && typeof term == "string" && term.length > 0){
|
||||
let mods = fs.readdirSync(modDirectory);
|
||||
let modsMatchingFilter = mods.filter(mod => mod.includes(term));
|
||||
if(modsMatchingFilter.length < 1){
|
||||
console.log("No mods found matching search");
|
||||
} else if(modsMatchingFilter.length == 1){
|
||||
console.log("Deleting "+modsMatchingFilter[0]);
|
||||
fs.unlinkSync(modDirectory+modsMatchingFilter[0]);
|
||||
console.log("Deleted.");
|
||||
} else if(modsMatchingFilter.length > 1){
|
||||
console.log("Found multiple mods, not doing anything");
|
||||
modsMatchingFilter.forEach(mod => console.log(mod));
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
Searches mods.factorio.com for mods matching a search term and prints
|
||||
the results to console as a neat looking table
|
||||
|
||||
Reference in new issue
Block a user