Skip to content
Myr

Improve backwards compatibility for command events (#1403)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Improve backwards compatibility for command events * Implement tests for legacy command event

authored by John Gee · committed by GitHub · parent 9b087c8 · Browse files · 2 files+43 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+43 added−2 removed

  • tests:+38 added−0 removed
  • other:+5 added−2 removed

2 files+43 added−2 removed

added:tests/command.onCommand.test.js+38 added
modified:index.js+5 added-2 removed
1488 unmodified lines
1489 if (parsed.unknown.length > 0) {1490 this.unknownOption(parsed.unknown[0]);1491 }14921493 const commandEvent = `command:${this.name()}`;1494 if (this._actionHandler) {1495 const args = this.args.slice();1496 this._args.forEach((arg, i) => {1497 if (arg.required && args[i] == null) {
3 unmodified lines
1501 }1502 });15031504 this._actionHandler(args);1504 this.emit('command:' + this.name(), operands, unknown);1505 if (this.parent) this.parent.emit(commandEvent, operands, unknown); // legacy1506 } else if (this.parent && this.parent.listenerCount(commandEvent)) {1507 this.parent.emit(commandEvent, operands, unknown); // legacy1508 } else if (operands.length) {1506 if (this._findCommand('*')) {1509 if (this._findCommand('*')) { // legacy1510 this._dispatchSubcommand('*', operands, unknown);1511 } else if (this.listenerCount('command:*')) {1512 this.emit('command:*', operands, unknown);1513 } else if (this.commands.length) {
662 unmodified lines