embark/lib/dashboard/repl.js

38 lines
783 B
JavaScript
Raw Normal View History

2018-07-23 12:30:58 +00:00
const repl = require("repl");
class REPL {
constructor(options) {
this.env = options.env;
2018-07-25 09:15:43 +00:00
this.plugins = options.plugins;
2018-07-23 12:30:58 +00:00
}
start(done) {
2018-07-23 16:05:01 +00:00
this.replServer = repl.start({
2018-07-24 08:40:48 +00:00
prompt: "Embark (" + this.env + ") > ",
useGlobal: true
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-25 09:15:43 +00:00
let self = this;
this.replServer.defineCommand('profile', {
help: 'Profile a contract',
action(contract) {
this.clearBufferedCommand();
let pluginCmds = self.plugins.getPluginsProperty('console', 'console');
for (let pluginCmd of pluginCmds) {
pluginCmd.call(self, `profile ${contract}`, {});
}
this.displayPrompt();
}
});
2018-07-23 12:30:58 +00:00
done();
}
2018-07-23 16:05:01 +00:00
2018-07-23 12:30:58 +00:00
}
module.exports = REPL;