Skip to content

Commit

Permalink
fix: correct check for compatible find binary (#10346)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Jul 31, 2020
1 parent 0708daf commit 2ab3fb2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
### Fixes

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

### Chore & Maintenance

Expand Down
6 changes: 5 additions & 1 deletion packages/jest-haste-map/src/crawlers/__tests__/node.test.js
Expand Up @@ -282,7 +282,11 @@ describe('node crawler', () => {
rootDir,
roots: ['/project/fruits'],
}).then(({hasteMap, removedFiles}) => {
expect(childProcess.spawn).lastCalledWith('find', ['.', '-iname', "''"]);
expect(childProcess.spawn).lastCalledWith(
'find',
['.', '-type', 'f', '(', '-iname', '*.ts', '-o', '-iname', '*.js', ')'],
{cwd: expect.any(String)},
);
expect(hasteMap.files).toEqual(
createMap({
'fruits/directory/strawberry.js': ['', 33, 42, 0, '', null],
Expand Down
17 changes: 14 additions & 3 deletions packages/jest-haste-map/src/crawlers/node.ts
Expand Up @@ -30,9 +30,20 @@ async function hasNativeFindSupport(

try {
return await new Promise(resolve => {
// Check the find binary supports the non-POSIX -iname parameter.
const args = ['.', '-iname', "''"];
const child = spawn('find', args);
// Check the find binary supports the non-POSIX -iname parameter wrapped in parens.
const args = [
'.',
'-type',
'f',
'(',
'-iname',
'*.ts',
'-o',
'-iname',
'*.js',
')',
];
const child = spawn('find', args, {cwd: __dirname});
child.on('error', () => {
resolve(false);
});
Expand Down

0 comments on commit 2ab3fb2

Please sign in to comment.