From d9573c3d0e7fca83cefb0bad8151a2a0dc2f3fc7 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 3 Nov 2018 01:28:15 +0330 Subject: [PATCH] fix: use live console._stdout bindings for default stream --- src/consola.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/consola.js b/src/consola.js index 5e733b25..cf70a054 100644 --- a/src/consola.js +++ b/src/consola.js @@ -11,11 +11,8 @@ export default class Consola { this._level = options.level != null ? options.level : 3 this._defaults = options.defaults || {} this._async = typeof options.async !== 'undefined' ? options.async : null - - if (typeof process !== 'undefined') { - this._stdout = options.stdout || process.stdout - this._stderr = options.stdout || process.stderr - } + this._stdout = options.stdout + this._stderr = options.stdout // Create logger functions for current instance for (const type in this._types) { @@ -230,8 +227,8 @@ export default class Consola { for (const reporter of this._reporters) { reporter.log(logObj, { async: false, - stdout: this._stdout, - stderr: this._stderr + stdout: this._stdout || console._stdout, // eslint-disable-line no-console + stderr: this._stderr || console._stderr // eslint-disable-line no-console }) } } @@ -240,8 +237,8 @@ export default class Consola { return Promise.all( this._reporters.map(reporter => reporter.log(logObj, { async: true, - stdout: this._stdout, - stderr: this._stderr + stdout: this._stdout || console._stdout, // eslint-disable-line no-console + stderr: this._stderr || console._stderr // eslint-disable-line no-console })) ) }