From ea4f3ab2bfac95322b277fd262a3943d97259d7c Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sat, 30 Nov 2019 00:04:35 +0100 Subject: [PATCH] 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. --- clusterctl.js | 32 +------------------------------- test/clusterctl.js | 8 -------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/clusterctl.js b/clusterctl.js index 193629e4..85d3a5c9 100644 --- a/clusterctl.js +++ b/clusterctl.js @@ -44,31 +44,6 @@ function formatOutputColored(output) { 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 */ @@ -282,11 +257,7 @@ class Control extends link.Link { async instanceOutputEventHandler(message) { let { instance_id, output } = message.data; - if (process.platform === "win32") { - console.log(formatOutput(output)); - } else { - console.log(formatOutputColored(output)); - } + console.log(formatOutputColored(output)); } } @@ -435,7 +406,6 @@ async function startControl() { module.exports = { // for testing only _formatOutputColored: formatOutputColored, - _formatOutput: formatOutput, _resolveInstance: resolveInstance, _Control: Control, diff --git a/test/clusterctl.js b/test/clusterctl.js index 37887918..9acb8791 100644 --- a/test/clusterctl.js +++ b/test/clusterctl.js @@ -22,14 +22,6 @@ describe("clusterctl", function() { 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(); mockConnector.on('send', function(message) {