From 2d21260ce6aabdf6464de1135dd8780ec1e752ca Mon Sep 17 00:00:00 2001 From: aleclarson Date: Mon, 19 Sep 2016 10:36:53 -0700 Subject: [PATCH] Check if node_modules dir exists before adding to search queue Summary: We can keep the `searchQueue` cleaner by using `this._fastfs.dirExists` on the potential `node_modules` directory. In addition to avoiding useless lookups, this also makes the error message provided by #9832 much more understandable. /cc davidaurelio Closes https://github.com/facebook/react-native/pull/9973 Differential Revision: D3887053 Pulled By: davidaurelio fbshipit-source-id: 6a5a488bb4217dd0f9db1c9c9f988b498c746ca9 --- .../src/node-haste/DependencyGraph/ResolutionRequest.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/react-packager/src/node-haste/DependencyGraph/ResolutionRequest.js b/react-packager/src/node-haste/DependencyGraph/ResolutionRequest.js index f0d8db30..b1fe2b93 100644 --- a/react-packager/src/node-haste/DependencyGraph/ResolutionRequest.js +++ b/react-packager/src/node-haste/DependencyGraph/ResolutionRequest.js @@ -358,9 +358,12 @@ class ResolutionRequest { for (let currDir = path.dirname(fromModule.path); currDir !== realPath.parse(fromModule.path).root; currDir = path.dirname(currDir)) { - searchQueue.push( - path.join(currDir, 'node_modules', realModuleName) - ); + let searchPath = path.join(currDir, 'node_modules'); + if (this._fastfs.dirExists(searchPath)) { + searchQueue.push( + path.join(searchPath, realModuleName) + ); + } } if (this._extraNodeModules) {