From 689e419e1d0bedccc6da6f9580d255c0e094fc60 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Sat, 16 Jan 2016 22:16:28 -0800 Subject: [PATCH] Add exit listener --- exec-wrap.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/exec-wrap.js b/exec-wrap.js index a909c1e..4065aa2 100644 --- a/exec-wrap.js +++ b/exec-wrap.js @@ -9,7 +9,6 @@ const path = require('path') , ctxFile = myargs[1] , ctx = JSON.parse(fs.readFileSync(ctxFile, 'utf8')) , mainProgram = ctx.mainProgram = fs.realpathSync(path.resolve(process.cwd(), myargs[2])) - , prexit = process.exit , isSolution = myargs[3] === 'solution' , isSubmission = myargs[3] === 'submission' @@ -74,17 +73,9 @@ function finish () { wrote = true } - -// just in case they use it -process.exit = function () { +process.on('exit', function () { finish() - prexit.apply(process, arguments) -} - +}) -try { - // run original main as if it were loaded directly - require(mainProgram) -} finally { - finish() -} +// run original main as if it were loaded directly +require(mainProgram)