Skip to content

Commit 4be69f1

Browse files
authored
Use getCommandAndParents for array of parents (#1566)
1 parent 56c4108 commit 4be69f1

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

lib/command.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,14 +1662,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
16621662
}
16631663
const context = this._getHelpContext(contextOptions);
16641664

1665-
const groupListeners = [];
1666-
let command = this;
1667-
while (command) {
1668-
groupListeners.push(command); // ordered from current command to root
1669-
command = command.parent;
1670-
}
1671-
1672-
groupListeners.slice().reverse().forEach(command => command.emit('beforeAllHelp', context));
1665+
getCommandAndParents(this).reverse().forEach(command => command.emit('beforeAllHelp', context));
16731666
this.emit('beforeHelp', context);
16741667

16751668
let helpInformation = this.helpInformation(context);
@@ -1683,7 +1676,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
16831676

16841677
this.emit(this._helpLongFlag); // deprecated
16851678
this.emit('afterHelp', context);
1686-
groupListeners.forEach(command => command.emit('afterAllHelp', context));
1679+
getCommandAndParents(this).forEach(command => command.emit('afterAllHelp', context));
16871680
};
16881681

16891682
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy