Skip to content

Commit effb4ef

Browse files
committed
add process.stdout.write trick to see if it works for error exit
1 parent 5360804 commit effb4ef

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

cli.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ var unhandledRejectionCount = 0;
4949
var uncaughtExceptionCount = 0;
5050
var errors = [];
5151

52-
function error(err) {
53-
console.error(err.stack);
52+
function error(error) {
53+
log.unexpectedExit(error);
54+
55+
// TODO: figure out why this needs to be here to
56+
// correctly flush the output when multiple test files
57+
process.stdout.write('');
58+
5459
setTimeout(function () {
5560
process.exit(1);
5661
}, 0);

lib/logger.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,14 @@ x.errors = function (results) {
5858
var i = 0;
5959

6060
results.forEach(function (result) {
61-
if (!(result.error && result.error.message)) {
61+
if (!result.error) {
6262
return;
6363
}
6464

6565
i++;
6666

6767
log.writelpad(chalk.red(i + '.', result.title));
68-
log.writelpad(chalk.red(beautifyStack(result.error.stack)));
69-
log.write();
68+
logError(result.error);
7069
});
7170
};
7271

@@ -90,21 +89,22 @@ x.unhandledRejections = function (file, rejections) {
9089
}
9190
rejections.forEach(function (rejection) {
9291
log.write(chalk.red('Unhandled Rejection: ', file));
93-
if (rejection.stack) {
94-
log.writelpad(chalk.red(beautifyStack(rejection.stack)));
95-
} else {
96-
log.writelpad(chalk.red(JSON.stringify(rejection)));
97-
}
98-
log.write();
92+
logError(rejection);
9993
});
10094
};
10195

10296
x.uncaughtException = function (file, error) {
10397
log.write(chalk.red('Uncaught Exception: ', file));
98+
logError(error);
99+
};
100+
101+
function logError(error) {
104102
if (error.stack) {
105103
log.writelpad(chalk.red(beautifyStack(error.stack)));
106104
} else {
107105
log.writelpad(chalk.red(JSON.stringify(error)));
108106
}
109107
log.write();
110-
};
108+
}
109+
110+
x.unexpectedExit = logError;

0 commit comments

Comments
 (0)