* Resolves hooks if they are a path to a file (instead of a `Function`).
( hooks: (string | F)[] | undefined, dir: string, )
| 42 | * Resolves hooks if they are a path to a file (instead of a `Function`). |
| 43 | */ |
| 44 | async function resolveHooks<F = HookFunction>( |
| 45 | hooks: (string | F)[] | undefined, |
| 46 | dir: string, |
| 47 | ) { |
| 48 | if (hooks) { |
| 49 | return await Promise.all( |
| 50 | hooks.map(async (hook) => |
| 51 | typeof hook === 'string' |
| 52 | ? ((await importSearch<F>(dir, [hook])) as F) |
| 53 | : hook, |
| 54 | ), |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | return []; |
| 59 | } |
| 60 | |
| 61 | type DoneFunction = (err?: Error) => void; |
| 62 | type PromisifiedHookFunction = ( |