* Load and parse a settings JSON file, returning only the hooks portion. * Returns null if file doesn't exist or fails to parse.
(filePath: string)
| 31 | * Returns null if file doesn't exist or fails to parse. |
| 32 | */ |
| 33 | function loadSettingsFile(filePath: string): HookSettingsFile | null { |
| 34 | try { |
| 35 | if (!fs.existsSync(filePath)) { |
| 36 | return null; |
| 37 | } |
| 38 | const content = fs.readFileSync(filePath, "utf-8"); |
| 39 | const parsed = JSON.parse(content); |
| 40 | return parsed as HookSettingsFile; |
| 41 | } catch (error) { |
| 42 | logger.warn(`Failed to load hooks settings from ${filePath}:`, error); |
| 43 | return null; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Merge two hook configs. Later config entries are appended (not replaced). |