diff --git a/lib/tap.js b/lib/tap.js index 14f541dbb..6e275039e 100644 --- a/lib/tap.js +++ b/lib/tap.js @@ -41,6 +41,15 @@ function monkeypatchExit () { return original.call(this, code) } }(process.reallyExit) + + process.exit = function (original) { + return function exit (code) { + code = onExitEvent(code) + return original.call(this, code) + } + }(process.exit) + + process.on('exit', onExitEvent) } var didOnExitEvent = false @@ -63,13 +72,14 @@ function onExitEvent (code) { } TAP.prototype.push = function push () { + // this resets push and pipe to standard values this.pipe(process.stdout) monkeypatchEpipe() monkeypatchExit() - process.on('exit', onExitEvent) - process.on('uncaughtException', tap.threw) - return this.push.apply(tap, arguments) + process.on('uncaughtException', this.threw) + + return this.push.apply(this, arguments) } TAP.prototype.onbail = function () {