MCPcopy Create free account
hub / github.com/continuedev/continue / getMatchingHookGroups

Function getMatchingHookGroups

extensions/cli/src/hooks/hookConfig.ts:133–164  ·  view source on GitHub ↗
(
  config: HooksConfig,
  eventName: string,
  matcherValue?: string,
)

Source from the content-addressed store, hash-verified

131 * @returns Array of matching hook handler groups
132 */
133export function getMatchingHookGroups(
134 config: HooksConfig,
135 eventName: string,
136 matcherValue?: string,
137): HookMatcherGroup[] {
138 const groups = config[eventName as keyof HooksConfig];
139 if (!groups) return [];
140
141 return groups.filter((group) => {
142 // No matcher, empty matcher, or "*" = match all
143 if (!group.matcher || group.matcher === "" || group.matcher === "*") {
144 return true;
145 }
146
147 // If no matcher value provided (e.g., events without matcher support), match all
148 if (matcherValue === undefined) {
149 return true;
150 }
151
152 // Regex match
153 try {
154 const regex = new RegExp(group.matcher);
155 return regex.test(matcherValue);
156 } catch (error) {
157 logger.warn(
158 `Invalid hook matcher regex "${group.matcher}" for event ${eventName}:`,
159 error,
160 );
161 return false;
162 }
163 });
164}

Callers 2

hooks.test.tsFile · 0.85
runHooksFunction · 0.85

Calls 2

testMethod · 0.80
warnMethod · 0.80

Tested by

no test coverage detected