Skip to content

Commit 79c5439

Browse files
fix: Use CODEFLASH_MONOREPO_ROOT for jest-runner resolution in loop-runner
The loop-runner from PR #1318 uses process.cwd() to resolve jest-runner, but in monorepos the cwd is the package directory, not the monorepo root. This fix checks CODEFLASH_MONOREPO_ROOT env var first (set by Python runner) before falling back to process.cwd(). This ensures jest-runner is found in monorepo root node_modules. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 5c3076a commit 79c5439

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

packages/codeflash/runtime/loop-runner.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ let jestVersion = 0;
4343
try {
4444
// Resolve jest-runner from the current working directory (project root)
4545
// This is important because the codeflash package may bundle a different version
46-
const projectRoot = process.cwd();
46+
// In monorepos, use CODEFLASH_MONOREPO_ROOT if available (set by Python runner)
47+
const projectRoot = process.env.CODEFLASH_MONOREPO_ROOT || process.cwd();
4748
const projectRequire = createRequire(path.join(projectRoot, 'node_modules', 'package.json'));
4849

4950
let jestRunnerPath;
5051
try {
51-
// First try to resolve from project's node_modules
52+
// First try to resolve from project's node_modules (or monorepo root)
5253
jestRunnerPath = projectRequire.resolve('jest-runner');
5354
} catch (e) {
5455
// Fall back to default resolution (codeflash's bundled version)

0 commit comments

Comments
 (0)