Skip to content

Commit

Permalink
feat: 执行hooks托底逻辑 (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinegoodman authored Mar 14, 2023
1 parent 6487308 commit 2d0ba7e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/wujie-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,12 @@ export function nextTick(cb: () => any): void {
//执行钩子函数
export function execHooks(plugins: Array<plugin>, hookName: string, ...args: Array<any>): void {
try {
plugins
.map((plugin) => plugin[hookName])
.filter((hook) => isFunction(hook))
.forEach((hook) => hook(...args));
if(plugins&&plugins.length>0){
plugins
.map((plugin) => plugin[hookName])
.filter((hook) => isFunction(hook))
.forEach((hook) => hook(...args));
}
} catch (e) {
error(e);
}
Expand Down

0 comments on commit 2d0ba7e

Please sign in to comment.