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