nodashboard start a repl

This commit is contained in:
Anthony Laibe 2018-07-23 17:05:01 +01:00
parent da1691327a
commit 3e328801db
3 changed files with 22 additions and 4 deletions

View File

@ -23,8 +23,13 @@ function registerVar(varName, code) {
__mainContext[varName] = code; __mainContext[varName] = code;
} }
function getContext() {
return __mainContext;
}
module.exports = { module.exports = {
doEval: doEval, doEval: doEval,
registerVar: registerVar, registerVar: registerVar,
initContext: initContext initContext: initContext,
getContext: getContext
}; };

View File

@ -1,4 +1,5 @@
const repl = require("repl"); const repl = require("repl");
const RunCode = require('../coderunner/runCode');
class REPL { class REPL {
constructor(options) { constructor(options) {
@ -6,16 +7,21 @@ class REPL {
} }
start(done) { start(done) {
let replServer = repl.start({ this.replServer = repl.start({
prompt: "Embark (" + this.env + ") > " prompt: "Embark (" + this.env + ") > "
}); });
this.initializeContext(this.replServer.context);
replServer.on('exit', () => { this.replServer.on("exit", () => {
process.exit(); process.exit();
}); });
done(); done();
} }
initializeContext(context) {
context.embark = RunCode.getContext();
}
} }
module.exports = REPL; module.exports = REPL;

View File

@ -155,7 +155,14 @@ class Embark {
}); });
} }
engine.startService("fileWatcher"); engine.startService("fileWatcher");
if (!options.useDashboard) {
const REPL = require('./dashboard/repl.js');
let repl = new REPL({env: engine.env});
repl.start(function () {
callback(); callback();
});
}
} }
], function (err, _result) { ], function (err, _result) {
if (err) { if (err) {