* Deep-merge two raw JSON objects. Both inputs must come from BEFORE Zod * parsing — otherwise Zod-filled defaults appear as if they were explicit * overrides and clobber genuine values from the other source. * * Plain object values merge recursively. Arrays, primitives, and `null` are * replac
(
base: Record<string, unknown>,
override: Record<string, unknown>,
)
| 154 | * other's entries. |
| 155 | */ |
| 156 | function deepMergeRawConfig( |
| 157 | base: Record<string, unknown>, |
| 158 | override: Record<string, unknown>, |
| 159 | ): Record<string, unknown> { |
| 160 | const result: Record<string, unknown> = { ...base }; |
| 161 | for (const key of Object.keys(override)) { |
| 162 | const baseVal = base[key]; |
| 163 | const overrideVal = override[key]; |
| 164 | if ( |
| 165 | baseVal !== null && |
| 166 | typeof baseVal === "object" && |
| 167 | !Array.isArray(baseVal) && |
| 168 | overrideVal !== null && |
| 169 | typeof overrideVal === "object" && |
| 170 | !Array.isArray(overrideVal) |
| 171 | ) { |
| 172 | result[key] = deepMergeRawConfig( |
| 173 | baseVal as Record<string, unknown>, |
| 174 | overrideVal as Record<string, unknown>, |
| 175 | ); |
| 176 | } else if ( |
| 177 | key === "disabled_hooks" && |
| 178 | Array.isArray(baseVal) && |
| 179 | Array.isArray(overrideVal) |
| 180 | ) { |
| 181 | // Union-merge so user + project can both disable hooks without |
| 182 | // one source erasing the other's entries. |
| 183 | result[key] = [...new Set([...baseVal, ...overrideVal])]; |
| 184 | } else { |
| 185 | result[key] = overrideVal; |
| 186 | } |
| 187 | } |
| 188 | return result; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Render a config value for a warning message in a way that never leaks resolved |
no outgoing calls
no test coverage detected