Skip to content

Commit

Permalink
stop search if is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
emuraton committed Jul 26, 2018
1 parent a10bc90 commit a432e4b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/jest-haste-map/src/crawlers/__tests__/node.test.js
Expand Up @@ -217,4 +217,20 @@ describe('node crawler', () => {
expect(data.files).toEqual({});
});
});

it('completes with undefined names', () => {
process.platform = 'win32';

nodeCrawl = require('../node');

const files = Object.create(null);
return nodeCrawl({
data: {files},
extensions: ['js'],
ignore: pearMatcher,
roots: ['/empty'],
}).then(data => {
expect(data.files).toEqual({});
});
});
});
5 changes: 4 additions & 1 deletion packages/jest-haste-map/src/crawlers/node.js
Expand Up @@ -30,7 +30,10 @@ function find(
activeCalls++;
fs.readdir(directory, (err, names) => {
activeCalls--;

if (!names) {
callback(result);
return;
}
names.forEach(file => {
file = path.join(directory, file);
if (ignore(file)) {
Expand Down

0 comments on commit a432e4b

Please sign in to comment.