embark-area-51/lib/dashboard/repl.js

28 lines
501 B
JavaScript
Raw Normal View History

2018-07-23 12:30:58 +00:00
const repl = require("repl");
2018-07-23 16:05:01 +00:00
const RunCode = require('../coderunner/runCode');
2018-07-23 12:30:58 +00:00
class REPL {
constructor(options) {
this.env = options.env;
}
start(done) {
2018-07-23 16:05:01 +00:00
this.replServer = repl.start({
2018-07-23 12:30:58 +00:00
prompt: "Embark (" + this.env + ") > "
});
2018-07-23 16:05:01 +00:00
this.initializeContext(this.replServer.context);
2018-07-23 12:30:58 +00:00
2018-07-23 16:05:01 +00:00
this.replServer.on("exit", () => {
2018-07-23 12:41:13 +00:00
process.exit();
});
2018-07-23 12:30:58 +00:00
done();
}
2018-07-23 16:05:01 +00:00
initializeContext(context) {
context.embark = RunCode.getContext();
}
2018-07-23 12:30:58 +00:00
}
module.exports = REPL;