Skip to content

Commit

Permalink
refactor: Simplify lifecycle event hooks resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Sep 20, 2021
1 parent be16ed5 commit 8b4498c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/classes/PluginManager.js
Expand Up @@ -554,9 +554,11 @@ class PluginManager {
return this.plugins;
}

getHooks(events) {
const eventsArray = [].concat(events);
return eventsArray.reduce((acc, event) => acc.concat(this.hooks[event] || []), []);
getHooks(lifecycleEventNames) {
if (!Array.isArray(lifecycleEventNames)) lifecycleEventNames = [lifecycleEventNames];
return _.flatten(
lifecycleEventNames.map((lifecycleEventName) => this.hooks[lifecycleEventName] || [])
);
}

async invoke(commandsArray, allowEntryPoints) {
Expand Down

0 comments on commit 8b4498c

Please sign in to comment.