mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
Remove uncoloured formatting of factorioOutput
Since chalk autodetects the color support in the terminal there is no need for a non-coloured version of formatOutput.
This commit is contained in:
1 parent
c6fd46e3c3
commit
ea4f3ab2bf
2 files changed
+1
-39
No files matched your search
+1
-31
@@ -44,31 +44,6 @@ function formatOutputColored(output) {
|
|||||||
return time + info + output.message;
|
return time + info + output.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Format a parsed Factorio output message
|
|
||||||
*
|
|
||||||
* Formats a parsed Factorio output from lib/factorio into a readable
|
|
||||||
* output string that can be printed
|
|
||||||
*/
|
|
||||||
function formatOutput(output) {
|
|
||||||
let time = "";
|
|
||||||
if (output.format === 'seconds') {
|
|
||||||
time = output.time.padStart(8) + ' ';
|
|
||||||
} else if (output.format === 'date') {
|
|
||||||
time = output.time + ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
let info = "";
|
|
||||||
if (output.type === 'log') {
|
|
||||||
info = output.level + ' ' + output.file + ': ';
|
|
||||||
|
|
||||||
} else if (output.type === 'action') {
|
|
||||||
info = '[' + output.action + '] ';
|
|
||||||
}
|
|
||||||
|
|
||||||
return time + info + output.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represens a command that can be runned by clusterctl
|
* Represens a command that can be runned by clusterctl
|
||||||
*/
|
*/
|
||||||
@@ -282,11 +257,7 @@ class Control extends link.Link {
|
|||||||
|
|
||||||
async instanceOutputEventHandler(message) {
|
async instanceOutputEventHandler(message) {
|
||||||
let { instance_id, output } = message.data;
|
let { instance_id, output } = message.data;
|
||||||
if (process.platform === "win32") {
|
console.log(formatOutputColored(output));
|
||||||
console.log(formatOutput(output));
|
|
||||||
} else {
|
|
||||||
console.log(formatOutputColored(output));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,7 +406,6 @@ async function startControl() {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
// for testing only
|
// for testing only
|
||||||
_formatOutputColored: formatOutputColored,
|
_formatOutputColored: formatOutputColored,
|
||||||
_formatOutput: formatOutput,
|
|
||||||
_resolveInstance: resolveInstance,
|
_resolveInstance: resolveInstance,
|
||||||
_Control: Control,
|
_Control: Control,
|
||||||
|
|
||||||
|
|||||||
@@ -22,14 +22,6 @@ describe("clusterctl", function() {
|
|||||||
chalk.level = old;
|
chalk.level = old;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("formatOutput()", function() {
|
|
||||||
it("should pass the test lines", function() {
|
|
||||||
for (let [reference, output] of testLines) {
|
|
||||||
let line = clusterctl._formatOutput(output);
|
|
||||||
assert.deepEqual(line, reference);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
let mockConnector = new mock.MockConnector();
|
let mockConnector = new mock.MockConnector();
|
||||||
mockConnector.on('send', function(message) {
|
mockConnector.on('send', function(message) {
|
||||||
|
|||||||
Reference in new issue
Block a user