From 94fa5597f7abcec131b9375891b0eae6cd6c2fd5 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Thu, 8 Jun 2017 21:09:55 -0700 Subject: [PATCH] Completes nodeCrawl with empty roots --- .../src/crawlers/__tests__/node-test.js | 17 +++++++++++++++++ packages/jest-haste-map/src/crawlers/node.js | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/jest-haste-map/src/crawlers/__tests__/node-test.js b/packages/jest-haste-map/src/crawlers/__tests__/node-test.js index e488f9d70215..edf90acbb10a 100644 --- a/packages/jest-haste-map/src/crawlers/__tests__/node-test.js +++ b/packages/jest-haste-map/src/crawlers/__tests__/node-test.js @@ -198,4 +198,21 @@ describe('node crawler', () => { }); }); }); + + it('completes with emtpy roots', () => { + process.platform = 'win32'; + + nodeCrawl = require('../node'); + + const files = Object.create(null); + return nodeCrawl({ + data: {files}, + extensions: ['js'], + forceNodeFilesystemAPI: true, + ignore: pearMatcher, + roots: [], + }).then(data => { + expect(data.files).toEqual({}); + }); + }); }); diff --git a/packages/jest-haste-map/src/crawlers/node.js b/packages/jest-haste-map/src/crawlers/node.js index 3b35c6cd40b8..a121ba236080 100644 --- a/packages/jest-haste-map/src/crawlers/node.js +++ b/packages/jest-haste-map/src/crawlers/node.js @@ -65,7 +65,11 @@ function find( }); } - roots.forEach(search); + if (roots.length > 0) { + roots.forEach(search); + } else { + callback(result); + } } function findNative(