We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 898d691 commit c60294bCopy full SHA for c60294b
packages/next-plugin/src/find-root.ts
@@ -4,16 +4,13 @@ import { dirname, join } from 'node:path'
4
export function findRoot(dir: string): string {
5
let root = dir
6
let prev = null
7
- const collectecd: string[] = []
+ let result: string = process.cwd()
8
while (prev === null || root !== prev) {
9
- if (existsSync(join(root, 'package.json')) && !collectecd.includes(root)) {
10
- collectecd.push(root)
+ if (existsSync(join(root, 'package.json'))) {
+ result = root
11
}
12
prev = root
13
root = dirname(root)
14
15
- if (collectecd.length > 0) {
16
- return collectecd.pop()!
17
- }
18
- return process.cwd()
+ return result
19
0 commit comments