( raw: unknown, diagnostics: PluginDiagnostic[], )
| 291 | } |
| 292 | |
| 293 | function readHooks( |
| 294 | raw: unknown, |
| 295 | diagnostics: PluginDiagnostic[], |
| 296 | ): readonly HookDefConfig[] | undefined { |
| 297 | if (raw === undefined) return undefined; |
| 298 | if (!Array.isArray(raw)) { |
| 299 | diagnostics.push({ severity: 'warn', message: '"hooks" must be an array' }); |
| 300 | return undefined; |
| 301 | } |
| 302 | const out: HookDefConfig[] = []; |
| 303 | raw.forEach((entry, i) => { |
| 304 | const parsed = HookDefSchema.safeParse(entry); |
| 305 | if (!parsed.success) { |
| 306 | diagnostics.push({ |
| 307 | severity: 'warn', |
| 308 | message: `Invalid hook at index ${i}: ${parsed.error.message}`, |
| 309 | }); |
| 310 | } else { |
| 311 | out.push(parsed.data); |
| 312 | } |
| 313 | }); |
| 314 | return out.length === 0 ? undefined : out; |
| 315 | } |
| 316 | |
| 317 | async function readCommands( |
| 318 | pluginRoot: string, |
no test coverage detected