[issue #59] Clear a possibly interrupted ANSI color code on signal termination.
This commit is contained in:
parent
af002db218
commit
70f8d4d4da
2 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue