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
This commit is contained in:
aleclarson 2016-09-19 10:36:53 -07:00 committed by Facebook Github Bot 6
parent 047cbf9d59
commit 2d21260ce6
1 changed files with 6 additions and 3 deletions

View File

@ -358,10 +358,13 @@ class ResolutionRequest {
for (let currDir = path.dirname(fromModule.path);
currDir !== realPath.parse(fromModule.path).root;
currDir = path.dirname(currDir)) {
let searchPath = path.join(currDir, 'node_modules');
if (this._fastfs.dirExists(searchPath)) {
searchQueue.push(
path.join(currDir, 'node_modules', realModuleName)
path.join(searchPath, realModuleName)
);
}
}
if (this._extraNodeModules) {
const bits = toModuleName.split('/');