From bc67dbbfd74b35c8a3d1a42986c1808020362b34 Mon Sep 17 00:00:00 2001 From: 1computer1 Date: Sat, 15 Jun 2019 20:08:03 -0400 Subject: [PATCH] Output both stderr and stdout --- src/listeners/messageInvalid.js | 8 +------- src/struct/LanguageHandler.js | 13 +++++++------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/listeners/messageInvalid.js b/src/listeners/messageInvalid.js index 8fe32e1..a2f3916 100644 --- a/src/listeners/messageInvalid.js +++ b/src/listeners/messageInvalid.js @@ -29,13 +29,7 @@ class MessageInvalidListener extends Listener { let errored = false; let result; try { - const { stdout, stderr } = await this.client.languageHandler.evalCode(parse); - if (stderr) { - errored = true; - result = stderr; - } else { - result = stdout; - } + ({ output: result, hasStderr: errored } = await this.client.languageHandler.evalCode(parse)); } catch (e) { errored = true; result = e.message; diff --git a/src/struct/LanguageHandler.js b/src/struct/LanguageHandler.js index f20df39..068b957 100644 --- a/src/struct/LanguageHandler.js +++ b/src/struct/LanguageHandler.js @@ -155,15 +155,16 @@ class LanguageHandler extends AkairoHandler { }, timeout); } - let stdout = ''; - let stderr = ''; + let output = ''; + let hasStderr = false; let error; proc.stdout.on('data', chunk => { - stdout += chunk; + output += chunk; }); proc.stderr.on('data', chunk => { - stderr += chunk; + hasStderr = true; + output += chunk; }); proc.on('error', e => { @@ -175,12 +176,12 @@ class LanguageHandler extends AkairoHandler { handled = true; if (status !== 0 || error) { if (!error) { - error = new Error(stderr || 'Something went wrong'); + error = new Error(output || 'Something went wrong'); } reject(error); } else { - resolve({ stdout, stderr }); + resolve({ output, hasStderr }); } } });