(packageName, startPath)
| 366 | * @param {String} the path of the directory to start searching from |
| 367 | */ |
| 368 | _findPackage(packageName, startPath) { |
| 369 | let parsedPath = path.parse(startPath); |
| 370 | let root = parsedPath.root; |
| 371 | |
| 372 | let currPath = startPath; |
| 373 | |
| 374 | while (currPath !== root) { |
| 375 | let endsWithNodeModules = path.basename(currPath) === 'node_modules'; |
| 376 | |
| 377 | let nodeModulesPath = endsWithNodeModules ? currPath : `${currPath}${path.sep}node_modules`; |
| 378 | |
| 379 | let nodeModulesList = this._readNodeModulesList(nodeModulesPath); |
| 380 | |
| 381 | // _readNodeModulesList only returns a NodeModulesList or null |
| 382 | if (nodeModulesList) { |
| 383 | let pkg = nodeModulesList.findPackage(packageName); |
| 384 | if (pkg) { |
| 385 | return pkg; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | currPath = path.dirname(currPath); |
| 390 | } |
| 391 | |
| 392 | return null; |
| 393 | } |
| 394 | |
| 395 | /** |
| 396 | * Given a directory that supposedly contains a package, create a PackageInfo |
no test coverage detected