mirror of https://github.com/embarklabs/embark.git
fix undefined message in console
This commit is contained in:
parent
70763fc717
commit
ddb1872db5
|
@ -369,7 +369,9 @@ class Monitor {
|
||||||
this.logText.log('console> '.bold.green + cmd);
|
this.logText.log('console> '.bold.green + cmd);
|
||||||
this.events.request('console:executeCmd', cmd, (err, result) => {
|
this.events.request('console:executeCmd', cmd, (err, result) => {
|
||||||
let message = err || result;
|
let message = err || result;
|
||||||
|
if (message) {
|
||||||
this.logText.log(message);
|
this.logText.log(message);
|
||||||
|
}
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(message);
|
cb(message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,23 @@
|
||||||
const repl = require("repl");
|
const repl = require("repl");
|
||||||
const util = require("util");
|
const util = require("util");
|
||||||
|
|
||||||
class REPL {
|
class REPL {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
this.env = options.env
|
this.env = options.env;
|
||||||
}
|
}
|
||||||
|
|
||||||
enhancedEval(cmd, context, filename, callback) {
|
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) {
|
enhancedWriter(output) {
|
||||||
if ((typeof output) === "string") {
|
if ((typeof output) === "string") {
|
||||||
return output;
|
return output;
|
||||||
} else {
|
|
||||||
return util.inspect(output, {colors: true});
|
|
||||||
}
|
}
|
||||||
|
return util.inspect(output, {colors: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
start(done) {
|
start(done) {
|
||||||
|
@ -36,7 +38,6 @@ class REPL {
|
||||||
|
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = REPL;
|
module.exports = REPL;
|
||||||
|
|
Loading…
Reference in New Issue