diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2017-12-16 01:29:19 -0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2017-12-20 01:33:25 -0300 |
commit | 1d6b729cea909769ac0bcb3aa68f5fe567c4ffb7 (patch) | |
tree | d55b51730686eca555500cd1675d66315166d75e /lib/console.js | |
parent | 5198a5359b3aa47a7a43686fdd86c7202ebac3b2 (diff) | |
download | node-new-1d6b729cea909769ac0bcb3aa68f5fe567c4ffb7.tar.gz |
console: make variables and checks stricter
PR-URL: https://github.com/nodejs/node/pull/17707
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/console.js')
-rw-r--r-- | lib/console.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/console.js b/lib/console.js index 8480ccfd46..654b5b8280 100644 --- a/lib/console.js +++ b/lib/console.js @@ -52,7 +52,7 @@ function Console(stdout, stderr, ignoreErrors = true) { Object.defineProperty(this, '_stdout', prop); prop.value = stderr; Object.defineProperty(this, '_stderr', prop); - prop.value = ignoreErrors; + prop.value = Boolean(ignoreErrors); Object.defineProperty(this, '_ignoreErrors', prop); prop.value = new Map(); Object.defineProperty(this, '_times', prop); @@ -80,7 +80,7 @@ function createWriteErrorHandler(stream) { // This conditional evaluates to true if and only if there was an error // that was not already emitted (which happens when the _write callback // is invoked asynchronously). - if (err && !stream._writableState.errorEmitted) { + if (err !== null && !stream._writableState.errorEmitted) { // If there was an error, it will be emitted on `stream` as // an `error` event. Adding a `once` listener will keep that error // from becoming an uncaught exception, but since the handler is @@ -102,7 +102,7 @@ function write(ignoreErrors, stream, string, errorhandler, groupIndent) { } string += '\n'; - if (!ignoreErrors) return stream.write(string); + if (ignoreErrors === false) return stream.write(string); // There may be an error occurring synchronously (e.g. for files or TTYs // on POSIX systems) or asynchronously (e.g. pipes on POSIX systems), so |