Skip to content

Commit 2ab3fb2

Browse files
authored
fix: correct check for compatible find binary (#10346)
1 parent 0708daf commit 2ab3fb2

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- `[jest-cli]` Use correct file name to override existing jest config on init ([#10337](https://github.com/facebook/jest/pull/10337))
8+
- `[jest-haste-map]` Properly detect support for native `find` ([#10346](https://github.com/facebook/jest/pull/10346))
89

910
### Chore & Maintenance
1011

packages/jest-haste-map/src/crawlers/__tests__/node.test.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,11 @@ describe('node crawler', () => {
282282
rootDir,
283283
roots: ['/project/fruits'],
284284
}).then(({hasteMap, removedFiles}) => {
285-
expect(childProcess.spawn).lastCalledWith('find', ['.', '-iname', "''"]);
285+
expect(childProcess.spawn).lastCalledWith(
286+
'find',
287+
['.', '-type', 'f', '(', '-iname', '*.ts', '-o', '-iname', '*.js', ')'],
288+
{cwd: expect.any(String)},
289+
);
286290
expect(hasteMap.files).toEqual(
287291
createMap({
288292
'fruits/directory/strawberry.js': ['', 33, 42, 0, '', null],

packages/jest-haste-map/src/crawlers/node.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,20 @@ async function hasNativeFindSupport(
3030

3131
try {
3232
return await new Promise(resolve => {
33-
// Check the find binary supports the non-POSIX -iname parameter.
34-
const args = ['.', '-iname', "''"];
35-
const child = spawn('find', args);
33+
// Check the find binary supports the non-POSIX -iname parameter wrapped in parens.
34+
const args = [
35+
'.',
36+
'-type',
37+
'f',
38+
'(',
39+
'-iname',
40+
'*.ts',
41+
'-o',
42+
'-iname',
43+
'*.js',
44+
')',
45+
];
46+
const child = spawn('find', args, {cwd: __dirname});
3647
child.on('error', () => {
3748
resolve(false);
3849
});

0 commit comments

Comments
 (0)