Skip to content

Commit 2596656

Browse files
committed
chore: move tool file check before function call
1 parent 2e2d82f commit 2596656

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

tests/index.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ async function getToolsWithFilteredCategories(
176176
continue;
177177
}
178178
const fileTools = await import(`../src/tools/${file}`);
179+
179180
for (const maybeTool of Object.values<unknown>(fileTools)) {
180181
let tool;
181182
if (typeof maybeTool === 'function') {
@@ -184,6 +185,11 @@ async function getToolsWithFilteredCategories(
184185
tool = maybeTool as ToolDefinition;
185186
}
186187

188+
// Skipping all files that are not tool files
189+
if (tool === null || typeof tool !== 'object' || !('name' in tool)) {
190+
continue;
191+
}
192+
187193
if (toolShouldBeSkipped(tool, filterOutCategories)) {
188194
continue;
189195
}
@@ -197,10 +203,6 @@ function toolShouldBeSkipped(
197203
tool: ToolDefinition,
198204
filteredOutCategories: ToolCategory[],
199205
) {
200-
if (tool === null || typeof tool !== 'object' || !('name' in tool)) {
201-
return true;
202-
}
203-
204206
if (tool.annotations?.conditions) {
205207
return true;
206208
}

0 commit comments

Comments
 (0)