Skip to content

Commit

Permalink
fix(plugin-system): Update invokeHook method signature
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivanpj committed Jan 9, 2024
1 parent a9aa24f commit f94ee01
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ jobs:
#- name: Generate configuration schema
# run: pnpm nx g @storm-software/workspace-tools:config-schema --outputPath=config.schema.json

- name: Add permissions to husky hooks
run: chmod a=rwx .husky/pre-push .husky/pre-commit .husky/post-merge .husky/post-commit .husky/post-checkout

- name: Build repository packages
run: pnpm nx run-many -t build --parallel=5

Expand Down
4 changes: 2 additions & 2 deletions docs/api-reports/packages/plugin-system/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ class PluginManager<
// (undocumented)
invokeHook: (
name: string,
handler: (context: TContext) => Promise<TContext> | TContext,
context: TContext
context: TContext,
handler?: ((context: TContext) => Promise<TContext> | TContext) | undefined
) => Promise<TContext>;
// (undocumented)
register: (provider: string) => Promise<PluginDefinition>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@
},
{
"kind": "Content",
"text": "(name: string, handler: (context: TContext) => "
"text": "(name: string, context: TContext, handler?: ((context: TContext) => "
},
{
"kind": "Reference",
Expand All @@ -2132,7 +2132,7 @@
},
{
"kind": "Content",
"text": "<TContext> | TContext, context: TContext) => "
"text": "<TContext> | TContext) | undefined) => "
},
{
"kind": "Reference",
Expand Down
9 changes: 6 additions & 3 deletions packages/plugin-system/src/manager/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ export class PluginManager<

public invokeHook = async (
name: string,
handler: (context: TContext) => Promise<TContext> | TContext,
context: TContext
context: TContext,
handler?: (context: TContext) => Promise<TContext> | TContext
): Promise<TContext> => {
let listeners = [] as PluginHookFn<TContext>[];
if (this.#hooks.has(name)) {
Expand Down Expand Up @@ -271,7 +271,10 @@ export class PluginManager<
}
}

nextContext = await Promise.resolve(handler(nextContext));
if (handler) {
nextContext = await Promise.resolve(handler(nextContext));
}

for (const callback of callbacks) {
nextContext = await Promise.resolve(callback(nextContext));
}
Expand Down

0 comments on commit f94ee01

Please sign in to comment.