MCPcopy
hub / github.com/claude-code-best/claude-code / mergeHooksSettings

Function mergeHooksSettings

src/utils/plugins/pluginLoader.ts:1855–1880  ·  view source on GitHub ↗

* Merge two HooksSettings objects

(
  base: HooksSettings | undefined,
  additional: HooksSettings,
)

Source from the content-addressed store, hash-verified

1853 * Merge two HooksSettings objects
1854 */
1855function mergeHooksSettings(
1856 base: HooksSettings | undefined,
1857 additional: HooksSettings,
1858): HooksSettings {
1859 if (!base) {
1860 return additional
1861 }
1862
1863 const merged = { ...base }
1864
1865 for (const [event, matchers] of Object.entries(additional) as [
1866 string,
1867 HookMatcher[],
1868 ][]) {
1869 if (!merged[event as keyof HooksSettings]) {
1870 merged[event as keyof HooksSettings] = matchers
1871 } else {
1872 // Merge matchers for this event
1873 const existing = ((merged[event as keyof HooksSettings] as unknown) ??
1874 []) as HookMatcher[]
1875 merged[event as keyof HooksSettings] = [...existing, ...matchers]
1876 }
1877 }
1878
1879 return merged
1880}
1881
1882/**
1883 * Shared discovery/policy/merge pipeline for both load modes.

Callers 1

createPluginFromPathFunction · 0.85

Calls 1

entriesMethod · 0.80

Tested by

no test coverage detected