Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: allow finding root with name
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 7, 2018
1 parent 755cd12 commit a559ee2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit a559ee2

Please sign in to comment.