feat: refs #5483 Split logging from logic #3
|
@ -1,13 +1,11 @@
|
|||
const EventEmitter = require('node:events');
|
||||
|
||||
/**
|
||||
* Base class for Myt commands.
|
||||
*/
|
||||
module.exports = class MytCommand extends EventEmitter {
|
||||
module.exports = class MytCommand{
|
||||
constructor(myt, opts) {
|
||||
super();
|
||||
this.myt = myt;
|
||||
this.opts = opts;
|
||||
this.handlers = {};
|
||||
}
|
||||
|
||||
async cli(myt, opts) {
|
||||
|
@ -27,4 +25,13 @@ module.exports = class MytCommand extends EventEmitter {
|
|||
async run(myt, opts) {
|
||||
throw new Error('run command not defined');
|
||||
}
|
||||
|
||||
on(event, handler) {
|
||||
this.handlers[event] = handler;
|
||||
}
|
||||
|
||||
emit(event, ...args) {
|
||||
const handler = this.handlers[event];
|
||||
if (handler) handler (...args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ class Run extends Command {
|
|||
this.emit('runningContainer');
|
||||
|
||||
const isRandom = opts.random;
|
||||
const dbConfig = Object.assign({}, opts.dbConfig);
|
||||
const dbConfig = opts.dbConfig;
|
||||
|
||||
let runOptions;
|
||||
|
||||
|
@ -193,6 +193,7 @@ class Run extends Command {
|
|||
}
|
||||
}
|
||||
|
||||
await conn.end();
|
||||
return server;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue