From ddb1872db554d21773dbe081914348cdd480e4f2 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 13 Sep 2018 10:28:03 -0400 Subject: [PATCH] fix undefined message in console --- cmd/dashboard/monitor.js | 4 +++- cmd/dashboard/repl.js | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/dashboard/monitor.js b/cmd/dashboard/monitor.js index eb2a256c..f1a10d90 100644 --- a/cmd/dashboard/monitor.js +++ b/cmd/dashboard/monitor.js @@ -369,7 +369,9 @@ class Monitor { this.logText.log('console> '.bold.green + cmd); this.events.request('console:executeCmd', cmd, (err, result) => { let message = err || result; - this.logText.log(message); + if (message) { + this.logText.log(message); + } if (cb) { cb(message); } diff --git a/cmd/dashboard/repl.js b/cmd/dashboard/repl.js index cdc724a9..3dac64ca 100644 --- a/cmd/dashboard/repl.js +++ b/cmd/dashboard/repl.js @@ -1,21 +1,23 @@ const repl = require("repl"); const util = require("util"); + class REPL { constructor(options) { this.events = options.events; - this.env = options.env + this.env = options.env; } enhancedEval(cmd, context, filename, callback) { - this.events.request('console:executeCmd', cmd.trim(), callback); + this.events.request('console:executeCmd', cmd.trim(), function (err, message) { + callback(err, message || ''); // This way, we don't print undefined + }); } enhancedWriter(output) { if ((typeof output) === "string") { return output; - } else { - return util.inspect(output, {colors: true}); } + return util.inspect(output, {colors: true}); } start(done) { @@ -36,7 +38,6 @@ class REPL { done(); } - } module.exports = REPL;