Skip to content

Commit

Permalink
fix: getClosestPackage method on DependencyGraph
Browse files Browse the repository at this point in the history
We cannot assume that `filePath` is _not_ a directory.
  • Loading branch information
aleclarson committed Jun 1, 2020
1 parent 55e7142 commit 205ed77
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/metro/src/node-haste/DependencyGraph.js
Expand Up @@ -117,9 +117,9 @@ class DependencyGraph extends EventEmitter {
}

_getClosestPackage(filePath: string): ?string {
const parsedPath = path.parse(filePath);
const root = parsedPath.root;
let dir = parsedPath.dir;
const {root} = path.parse(filePath);
// The `filePath` may be a directory.
let dir = filePath;
do {
const candidate = path.join(dir, 'package.json');
if (this._hasteFS.exists(candidate)) {
Expand Down

0 comments on commit 205ed77

Please sign in to comment.