(basename)
| 314 | // .babelrc), and return the absolute path of the first one found, or |
| 315 | // null if the search failed. |
| 316 | findControlFile(basename) { |
| 317 | let absPath = this._controlFileCache[basename]; |
| 318 | if (typeof absPath === "string") { |
| 319 | return absPath; |
| 320 | } |
| 321 | |
| 322 | const sourceRoot = this.getSourceRoot(true); |
| 323 | if (! _.isString(sourceRoot)) { |
| 324 | return this._controlFileCache[basename] = null; |
| 325 | } |
| 326 | |
| 327 | let dir = files.pathDirname( |
| 328 | files.pathJoin(sourceRoot, this.getPathInPackage())); |
| 329 | |
| 330 | while (true) { |
| 331 | absPath = files.pathJoin(dir, basename); |
| 332 | |
| 333 | const stat = this._stat(absPath); |
| 334 | if (stat && stat.isFile()) { |
| 335 | return this._controlFileCache[basename] = absPath; |
| 336 | } |
| 337 | |
| 338 | if (files.pathBasename(dir) === "node_modules") { |
| 339 | // The search for control files should not escape node_modules. |
| 340 | return this._controlFileCache[basename] = null; |
| 341 | } |
| 342 | |
| 343 | if (dir === sourceRoot) break; |
| 344 | let parentDir = files.pathDirname(dir); |
| 345 | if (parentDir === dir) break; |
| 346 | dir = parentDir; |
| 347 | } |
| 348 | |
| 349 | return this._controlFileCache[basename] = null; |
| 350 | } |
| 351 | |
| 352 | _resolveCacheLookup(id, parentPath) { |
| 353 | const byId = this._resolveCache[id]; |
no test coverage detected