Skip to content

Commit

Permalink
Wrap emit to preserve callback order when async (#1638)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn authored Nov 9, 2021
1 parent e649291 commit 35a028b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
let actionResult;
actionResult = this._chainOrCallHooks(actionResult, 'preAction');
actionResult = this._chainOrCall(actionResult, () => this._actionHandler(this.processedArgs));
if (this.parent) this.parent.emit(commandEvent, operands, unknown); // legacy
if (this.parent) {
actionResult = this._chainOrCall(actionResult, () => {
this.parent.emit(commandEvent, operands, unknown); // legacy
});
}
actionResult = this._chainOrCallHooks(actionResult, 'postAction');
return actionResult;
}
Expand Down

0 comments on commit 35a028b

Please sign in to comment.