Skip to content

Commit d7a299a

Browse files
realpathSync
1 parent 94bbc56 commit d7a299a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

packages/config/jest/index.mjs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import path from 'path';
22
import { fileURLToPath } from 'url';
3-
import { existsSync, readdirSync, readFileSync } from 'fs';
4-
5-
const packagesDir = path.join(
6-
path.dirname(fileURLToPath(import.meta.url)),
7-
'..',
8-
'..',
9-
'..',
10-
'/',
11-
);
3+
import { existsSync, readdirSync, readFileSync, realpathSync } from 'fs';
4+
5+
// Resolve symlinks so import.meta.url always points to the real file path,
6+
// even when Jest resolves through node_modules symlinks.
7+
const configDir = realpathSync(path.dirname(fileURLToPath(import.meta.url)));
8+
const packagesDir = path.join(configDir, '..', '..', '..', '/');
129

1310
function escapeRegex(str) {
1411
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');

0 commit comments

Comments
 (0)