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,9 +358,12 @@ class ResolutionRequest {
for (let currDir = path.dirname(fromModule.path); for (let currDir = path.dirname(fromModule.path);
currDir !== realPath.parse(fromModule.path).root; currDir !== realPath.parse(fromModule.path).root;
currDir = path.dirname(currDir)) { currDir = path.dirname(currDir)) {
searchQueue.push( let searchPath = path.join(currDir, 'node_modules');
path.join(currDir, 'node_modules', realModuleName) if (this._fastfs.dirExists(searchPath)) {
); searchQueue.push(
path.join(searchPath, realModuleName)
);
}
} }
if (this._extraNodeModules) { if (this._extraNodeModules) {