Skip to content

Commit 29f3c88

Browse files
refactor(index.ts): filter out test files from activity modules
- Updated the activity module import logic in index.ts to exclude test files (ending with .test.ts and .test.js) from being loaded. This change ensures that only relevant activity modules are included, improving the clarity and performance of the worker. These modifications enhance the organization of the codebase by preventing unnecessary test files from being processed.
1 parent 5c402e9 commit 29f3c88

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

workers/main/src/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ import { Connection, ScheduleClient } from '@temporalio/client';
66
const workflowsPath = path.join(__dirname, 'workflows');
77
const activitiesPath = path.join(__dirname, 'activities');
88

9-
const workflowModules = readdirSync(workflowsPath)
10-
.filter((f: string) => f.endsWith('.ts') || f.endsWith('.js'))
11-
.map((f: string) => require(path.join(workflowsPath, f)));
12-
139
const activityModules = readdirSync(activitiesPath)
14-
.filter((f: string) => f.endsWith('.ts') || f.endsWith('.js'))
10+
.filter((f: string) => f.endsWith('.ts') || f.endsWith('.js') && !f.endsWith('.test.ts') && !f.endsWith('.test.js'))
1511
.map((f: string) => require(path.join(activitiesPath, f)));
1612

1713
const activities = Object.assign({}, ...activityModules);

0 commit comments

Comments
 (0)