From 4f4e687a178d011ef224b48514b4c58f36f381f5 Mon Sep 17 00:00:00 2001 From: caub Date: Wed, 28 Aug 2019 22:16:22 +0200 Subject: [PATCH] Don't forget stderr --- src/plugins/js-eval/__tests__/jsEvalPlugin-test.js | 3 +++ src/plugins/js-eval/jsEval.js | 4 ++++ src/plugins/js-eval/jsEvalPlugin.js | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/js-eval/__tests__/jsEvalPlugin-test.js b/src/plugins/js-eval/__tests__/jsEvalPlugin-test.js index ad0dae5..b77272e 100644 --- a/src/plugins/js-eval/__tests__/jsEvalPlugin-test.js +++ b/src/plugins/js-eval/__tests__/jsEvalPlugin-test.js @@ -24,6 +24,9 @@ describe('jsEvalPlugin', () => { const output2 = await testEval('n> setTimeout(() => console.log(2), 1000); 1'); expect(output2).toEqual('(okay) 12'); + + const output3 = await testEval('n> console.warn("test")'); + expect(output3).toEqual(`(okay) test\nundefined`); }); it(`errors when it should`, async () => { diff --git a/src/plugins/js-eval/jsEval.js b/src/plugins/js-eval/jsEval.js index 7d52885..676c578 100644 --- a/src/plugins/js-eval/jsEval.js +++ b/src/plugins/js-eval/jsEval.js @@ -30,6 +30,10 @@ const jsEval = (code, environment = 'node-cjs', timeout = 5000, cmd = []) => new data += chunk; }); + proc.stderr.on('data', (chunk) => { + data += chunk; + }); + proc.on('error', (e) => { clearTimeout(timer); reject(e); diff --git a/src/plugins/js-eval/jsEvalPlugin.js b/src/plugins/js-eval/jsEvalPlugin.js index 60d87ce..c092dad 100644 --- a/src/plugins/js-eval/jsEvalPlugin.js +++ b/src/plugins/js-eval/jsEvalPlugin.js @@ -7,7 +7,7 @@ const helpMsg = `n> node stable, h> node harmony, b> babel, s> node vm.Script, m // default jseval run command const CMD = ['node', '--no-warnings', '/run/run.js']; -const CMD_SHIMS = ['node', '-r', '/run/node_modules/airbnb-js-shims/target/es2019', '/run/run.js']; +const CMD_SHIMS = ['node', '-r', '/run/node_modules/airbnb-js-shims/target/es2019', '--no-warnings', '/run/run.js']; const CMD_HARMONY = ['node', '--harmony', '--experimental-vm-modules', '--experimental-modules', '--no-warnings', '/run/run.js']; const jsEvalPlugin = async ({ mentionUser, respond, message, selfConfig = {} }) => {