Add dedicated writer for string result

This commit is contained in:
Anthony Laibe 2018-07-26 16:56:50 +01:00 committed by Iuri Matias
parent d5911cb3b7
commit 36ae882a26
1 changed files with 11 additions and 1 deletions

View File

@ -1,4 +1,5 @@
const repl = require("repl");
const util = require("util");
const Console = require('./console.js');
@ -20,11 +21,20 @@ class REPL {
});
}
enhancedWriter(output) {
if ((typeof output) === "string") {
return output;
} else {
return util.inspect(output, {colors: true});
}
}
start(done) {
this.replServer = repl.start({
prompt: "Embark (" + this.env + ") > ",
useGlobal: true,
eval: this.enhancedEval.bind(this)
eval: this.enhancedEval.bind(this),
writer: this.enhancedWriter.bind(this)
});
this.replServer.on("exit", () => {