From 4e99ee3231d69f1e4927e6a14d90b1521917c205 Mon Sep 17 00:00:00 2001 From: Menci Date: Thu, 25 Apr 2019 10:39:50 +0800 Subject: [PATCH] Fix uncaught exception in code formatter --- libs/code_formatter.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/code_formatter.js b/libs/code_formatter.js index 2b50a01..62c2996 100644 --- a/libs/code_formatter.js +++ b/libs/code_formatter.js @@ -35,16 +35,16 @@ module.exports = async (code, lang) => { } await new Promise((resolve, reject) => { - let exit = code => { - if (code === 0) resolve(); - else reject(code); + let exit = () => { + if (process.exitCode === 0) resolve(); + else reject(process.exitCode); } - if (process.exitCode !== null) exit(process.exitCode); - else process.on('close', exit); + if (process.exitCode !== null) exit(); + else process.on('close', () => exit()); }); } catch (e) { - console.log(e.stack); + console.log(e); result = null; }