From a559ee2b3116fd3e2eb5ccf77904a1009c20a280 Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Tue, 6 Feb 2018 20:39:16 -0800 Subject: [PATCH] fix: allow finding root with name --- src/plugin.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugin.ts b/src/plugin.ts index 00080eb4..4353b7e7 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -244,9 +244,14 @@ function findRoot(name: string | undefined, root: string) { let cur if (name) { cur = path.join(next, 'node_modules', name, 'package.json') + if (fs.existsSync(cur)) return path.dirname(cur) + try { + let pkg = loadJSONSync(path.join(next, 'package.json')) + if (pkg.name === name) return next + } catch {} } else { cur = path.join(next, 'package.json') + if (fs.existsSync(cur)) return path.dirname(cur) } - if (fs.existsSync(cur)) return path.dirname(cur) } }