From 326e12d23aedcd3517dfc6081e6ddcaf4828b009 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 22 Aug 2018 14:23:23 -0400 Subject: [PATCH] fix one with variable --- lib/core/modules/coderunner/codeRunner.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/core/modules/coderunner/codeRunner.js b/lib/core/modules/coderunner/codeRunner.js index 9b965e69..14484c86 100644 --- a/lib/core/modules/coderunner/codeRunner.js +++ b/lib/core/modules/coderunner/codeRunner.js @@ -43,16 +43,15 @@ class CodeRunner { } const awaitIdx = code.indexOf('await'); if (awaitIdx > -1) { - let end = code.length; - if (code[end - 1] === ';') { - end--; // Remove the `;` because we add function calls - } if (awaitIdx < 2) { + let end = code.length; + if (code[end - 1] === ';') { + end--; // Remove the `;` because we add function calls + } code = code.substring(5, end); // remove await keyword code += '.then(console.log).catch(console.error);'; // Add promise catch } else { - code = code.substring(0, end); // remove ending `;` - code = `(async function() {${code}.then(console.log);})();`; + code = `(async function() {${code}})();`; } } let result = RunCode.doEval(code);