mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 16:13:12 +09:00
Added more comments, added quotes around strings
This commit is contained in:
1 parent
4398d33fea
commit
71fb8541d5
1 file changed
+15
-8
+15
-8
@@ -125,25 +125,33 @@ masterConfigCommands.add(new libCommand.Command({
|
|||||||
editor = process.env.VISUAL
|
editor = process.env.VISUAL
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
// needed for the process.env statements to not be flagged by eslint
|
// needed for the process.env statements to not be flagged by eslint
|
||||||
|
// prio for editors is CLI arg > env.EDITOR > env.VISUAL
|
||||||
} else {
|
} else {
|
||||||
throw new libErrors.CommandError("No editor avalible. Checked CLI input, EDITOR and VISUAL env vars");
|
throw new libErrors.CommandError("No editor avalible. Checked CLI input, EDITOR and VISUAL env vars");
|
||||||
}
|
}
|
||||||
|
|
||||||
let allConfigElements = "";
|
let allConfigElements = "";
|
||||||
for (let group of response.serialized_config.groups) {
|
for (let group of response.serialized_config.groups) {
|
||||||
for (let [name, value] of Object.entries(group.fields)) {
|
for (let [name, value] of Object.entries(group.fields)) {
|
||||||
// needed for line lenght; IMO this is more readable then using a temp var
|
if (typeof value === "string") {
|
||||||
// eslint-disable-next-line
|
value = `\"${value}\"`;
|
||||||
allConfigElements += `# ${libConfig.MasterConfig.groups.get(group.name)._definitions.get(name).description}\n`;
|
}
|
||||||
allConfigElements += `${group.name}.${name} ${JSON.stringify(value)}\n\n`;
|
// put quotes around value if it's a string
|
||||||
|
|
||||||
|
let desc = libConfig.MasterConfig.groups.get(group.name)._definitions.get(name).description;
|
||||||
|
allConfigElements += `# ${desc}\n`;
|
||||||
|
// split onto two lines for readability and es-lint
|
||||||
|
|
||||||
|
allConfigElements += `${group.name}.${name} ${value}\n\n`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print(allConfigElements);
|
// use same method as master config list to grab values, with a small modification to add quotes around strings
|
||||||
fs.writeFile(tmpFile, allConfigElements, (err) => {
|
fs.writeFile(tmpFile, allConfigElements, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
print(allConfigElements);
|
|
||||||
async function afterEditorDone() {
|
async function afterEditorDone() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,8 +164,7 @@ masterConfigCommands.add(new libCommand.Command({
|
|||||||
process.stdout.pipe(data);
|
process.stdout.pipe(data);
|
||||||
});
|
});
|
||||||
editorSpawn.on("err", (err) => {
|
editorSpawn.on("err", (err) => {
|
||||||
print(err);
|
throw new libErrors.CommandError(err);
|
||||||
throw new libErrors.CommandError("Editor throwed error.");
|
|
||||||
});
|
});
|
||||||
editorSpawn.on("exit", (exit) => {
|
editorSpawn.on("exit", (exit) => {
|
||||||
afterEditorDone();
|
afterEditorDone();
|
||||||
|
|||||||
Reference in new issue
Block a user