mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-26 08:33:12 +09:00
Implemented editing configs using node client.js manager #59
This commit is contained in:
1 parent
1dd58c27e0
commit
682856c0a5
1 file changed
+9
-2
@@ -4,6 +4,7 @@ Provides tools for managing both masters and slaves config files.
|
|||||||
*/
|
*/
|
||||||
// require modules
|
// require modules
|
||||||
const asTable = require("as-table").configure({delimiter: ' | '});
|
const asTable = require("as-table").configure({delimiter: ' | '});
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
// internal requires
|
// internal requires
|
||||||
var config = require("./../../config");
|
var config = require("./../../config");
|
||||||
@@ -30,11 +31,17 @@ module.exports.editConfig = function(instance, entry, newValue){
|
|||||||
if(!instance || instance == "shared"){
|
if(!instance || instance == "shared"){
|
||||||
if(config[entry] && newValue){
|
if(config[entry] && newValue){
|
||||||
if(objectOps.isJSON(newValue)){
|
if(objectOps.isJSON(newValue)){
|
||||||
console.log("Changing config entry "+entry+" from "+JSON.stringify(config[entry])+" to "+JSON.stringify(newValue));
|
|
||||||
config[entry] = JSON.parse(newValue);
|
config[entry] = JSON.parse(newValue);
|
||||||
|
console.log("Changed config entry "+entry+" from "+JSON.stringify(config[entry])+" to "+JSON.stringify(newValue));
|
||||||
|
console.log("new config file:");
|
||||||
|
console.log(JSON.stringify(config, null, " "))
|
||||||
|
fs.writeFileSync("config.json", JSON.stringify(config, null, 4));
|
||||||
} else {
|
} else {
|
||||||
console.log("Changing config entry "+entry+" from "+config[entry]+" to '"+newValue+"'");
|
|
||||||
config[entry] = newValue;
|
config[entry] = newValue;
|
||||||
|
console.log("Changed config entry "+entry+" from "+config[entry]+" to '"+newValue+"'");
|
||||||
|
console.log("new config file:");
|
||||||
|
console.log(JSON.stringify(config, null, " "))
|
||||||
|
fs.writeFileSync("config.json", JSON.stringify(config, null, 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user