Skip to content

Commit 41e2bb1

Browse files
BridgeARMylesBorins
authored andcommitted
console: make variables and checks stricter
PR-URL: #17707 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 0573c0f commit 41e2bb1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/console.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function Console(stdout, stderr, ignoreErrors = true) {
5252
Object.defineProperty(this, '_stdout', prop);
5353
prop.value = stderr;
5454
Object.defineProperty(this, '_stderr', prop);
55-
prop.value = ignoreErrors;
55+
prop.value = Boolean(ignoreErrors);
5656
Object.defineProperty(this, '_ignoreErrors', prop);
5757
prop.value = new Map();
5858
Object.defineProperty(this, '_times', prop);
@@ -80,7 +80,7 @@ function createWriteErrorHandler(stream) {
8080
// This conditional evaluates to true if and only if there was an error
8181
// that was not already emitted (which happens when the _write callback
8282
// is invoked asynchronously).
83-
if (err && !stream._writableState.errorEmitted) {
83+
if (err !== null && !stream._writableState.errorEmitted) {
8484
// If there was an error, it will be emitted on `stream` as
8585
// an `error` event. Adding a `once` listener will keep that error
8686
// from becoming an uncaught exception, but since the handler is
@@ -102,7 +102,7 @@ function write(ignoreErrors, stream, string, errorhandler, groupIndent) {
102102
}
103103
string += '\n';
104104

105-
if (!ignoreErrors) return stream.write(string);
105+
if (ignoreErrors === false) return stream.write(string);
106106

107107
// There may be an error occurring synchronously (e.g. for files or TTYs
108108
// on POSIX systems) or asynchronously (e.g. pipes on POSIX systems), so

0 commit comments

Comments
 (0)