[issue #59] Clear a possibly interrupted ANSI color code on signal termination.

master
Trent Mick 2012-11-14 19:27:53 -08:00
parent af002db218
commit 70f8d4d4da
2 changed files with 10 additions and 1 deletions

View File

@ -2,7 +2,8 @@
## bunyan 0.16.7 (not yet released)
(nothing yet)
- [issue #59] Clear a possibly interrupted ANSI color code on signal
termination.
## bunyan 0.16.6

View File

@ -73,6 +73,9 @@ var currLine = null;
// Child dtrace process, if any. Used for signal-handling.
var child = null;
// Whether ANSI codes are being used. Used for signal-handling.
var usingAnsiCodes = false;
//---- support functions
@ -1147,6 +1150,10 @@ function asyncForEach(arr, iterator, callback) {
// Try to ensure we close a child 'dtrace' process on signalled exit.
function signalCleanupAndExit(signal) {
if (usingAnsiCodes) {
// Clear possibly interrupted ANSI code (issue #59).
process.stdout.write('\033[0m');
}
if (child) {
child.kill(signal);
}
@ -1215,6 +1222,7 @@ function main(argv) {
opts.color = process.stdout.isTTY;
}
}
usingAnsiCodes = opts.color; // intentionally global
var stylize = (opts.color ? stylizeWithColor : stylizeWithoutColor);
var retval = 0;