From 205ed779c38c8304ca6dd16138718439f752eb12 Mon Sep 17 00:00:00 2001 From: aleclarson Date: Mon, 24 Dec 2018 22:34:36 -0500 Subject: [PATCH] fix: getClosestPackage method on DependencyGraph We cannot assume that `filePath` is _not_ a directory. --- packages/metro/src/node-haste/DependencyGraph.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/metro/src/node-haste/DependencyGraph.js b/packages/metro/src/node-haste/DependencyGraph.js index 3eb0515d3c..22425f813d 100644 --- a/packages/metro/src/node-haste/DependencyGraph.js +++ b/packages/metro/src/node-haste/DependencyGraph.js @@ -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)) {