Skip to content

Commit c2b2faa

Browse files
authored
fix: optimize match siblings (#15722)
1 parent 81e7b33 commit c2b2faa

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/jest-runtime/src/helpers.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@ export const findSiblingsWithFileExtension = (
4343

4444
const matches = glob
4545
.sync(`${pathToModule}.*`, {windowsPathsNoEscape: true})
46-
.map(match => slash(match))
4746
.map(match => {
48-
const relativePath = path.posix.relative(slashedDirname, match);
47+
const slashedMap = slash(match);
48+
const relativePath = path.posix.relative(slashedDirname, slashedMap);
4949

50-
return path.posix.dirname(match) === slashedDirname
51-
? `./${relativePath}`
52-
: relativePath;
50+
const slashedPath =
51+
path.posix.dirname(slashedMap) === slashedDirname
52+
? `./${relativePath}`
53+
: relativePath;
54+
55+
return `\t'${slashedPath}'`;
5356
})
54-
.map(match => `\t'${match}'`)
5557
.join('\n');
5658

5759
if (matches) {

0 commit comments

Comments
 (0)