Skip to content

Commit a432e4b

Browse files
committed
stop search if is undefined
1 parent a10bc90 commit a432e4b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,20 @@ describe('node crawler', () => {
217217
expect(data.files).toEqual({});
218218
});
219219
});
220+
221+
it('completes with undefined names', () => {
222+
process.platform = 'win32';
223+
224+
nodeCrawl = require('../node');
225+
226+
const files = Object.create(null);
227+
return nodeCrawl({
228+
data: {files},
229+
extensions: ['js'],
230+
ignore: pearMatcher,
231+
roots: ['/empty'],
232+
}).then(data => {
233+
expect(data.files).toEqual({});
234+
});
235+
});
220236
});

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ function find(
3030
activeCalls++;
3131
fs.readdir(directory, (err, names) => {
3232
activeCalls--;
33-
33+
if (!names) {
34+
callback(result);
35+
return;
36+
}
3437
names.forEach(file => {
3538
file = path.join(directory, file);
3639
if (ignore(file)) {

0 commit comments

Comments
 (0)