* Merge settings from all enabled plugins into a single record. * Later plugins override earlier ones for the same key. * Only allowlisted keys are included (filtering happens at load time).
( plugins: LoadedPlugin[], )
| 3251 | * Only allowlisted keys are included (filtering happens at load time). |
| 3252 | */ |
| 3253 | function mergePluginSettings( |
| 3254 | plugins: LoadedPlugin[], |
| 3255 | ): Record<string, unknown> | undefined { |
| 3256 | let merged: Record<string, unknown> | undefined |
| 3257 | |
| 3258 | for (const plugin of plugins) { |
| 3259 | if (!plugin.settings) { |
| 3260 | continue |
| 3261 | } |
| 3262 | |
| 3263 | if (!merged) { |
| 3264 | merged = {} |
| 3265 | } |
| 3266 | |
| 3267 | for (const [key, value] of Object.entries(plugin.settings)) { |
| 3268 | if (key in merged) { |
| 3269 | logForDebugging( |
| 3270 | `Plugin "${plugin.name}" overrides setting "${key}" (previously set by another plugin)`, |
| 3271 | ) |
| 3272 | } |
| 3273 | merged[key] = value |
| 3274 | } |
| 3275 | } |
| 3276 | |
| 3277 | return merged |
| 3278 | } |
| 3279 | |
| 3280 | /** |
| 3281 | * Store merged plugin settings in the synchronous cache. |
no test coverage detected