28 lines
501 B
JavaScript
Raw Normal View History

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