( childTrace: typeof autoTrace, forgeConfig: ResolvedForgeConfig, hookName: Hook, ...hookArgs: ForgeSimpleHookSignatures[Hook] )
| 33 | }; |
| 34 | |
| 35 | export const getHookListrTasks = async < |
| 36 | Hook extends keyof ForgeSimpleHookSignatures, |
| 37 | >( |
| 38 | childTrace: typeof autoTrace, |
| 39 | forgeConfig: ResolvedForgeConfig, |
| 40 | hookName: Hook, |
| 41 | ...hookArgs: ForgeSimpleHookSignatures[Hook] |
| 42 | ): Promise<ForgeListrTaskDefinition[]> => { |
| 43 | const { hooks } = forgeConfig; |
| 44 | const tasks: ForgeListrTaskDefinition[] = []; |
| 45 | if (hooks) { |
| 46 | d(`hook triggered: ${hookName}`); |
| 47 | if (typeof hooks[hookName] === 'function') { |
| 48 | d('calling hook:', hookName, 'with args:', hookArgs); |
| 49 | tasks.push({ |
| 50 | title: `Running ${chalk.yellow(hookName)} hook from forgeConfig`, |
| 51 | task: childTrace( |
| 52 | { |
| 53 | name: 'forge-config-hook', |
| 54 | category: '@electron-forge/hooks', |
| 55 | extraDetails: { hook: hookName }, |
| 56 | }, |
| 57 | async () => { |
| 58 | await (hooks[hookName] as ForgeSimpleHookFn<Hook>)( |
| 59 | forgeConfig, |
| 60 | ...hookArgs, |
| 61 | ); |
| 62 | }, |
| 63 | ), |
| 64 | }); |
| 65 | } |
| 66 | } |
| 67 | tasks.push( |
| 68 | ...(await forgeConfig.pluginInterface.getHookListrTasks( |
| 69 | childTrace, |
| 70 | hookName, |
| 71 | hookArgs, |
| 72 | )), |
| 73 | ); |
| 74 | return tasks; |
| 75 | }; |
| 76 | |
| 77 | export async function runMutatingHook< |
| 78 | Hook extends keyof ForgeMutatingHookSignatures, |
no test coverage detected