Skip to content

Commit 3008712

Browse files
committed
avoid infinite loop when invoked sans package.json
1 parent deabbc7 commit 3008712

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/getAppRootPath.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import { existsSync } from "fs-extra"
55
export const getAppRootPath = (): string => {
66
let cwd = process.cwd()
77
while (!existsSync(join(cwd, "package.json"))) {
8-
cwd = resolve(cwd, "../")
8+
const up = resolve(cwd, "../")
9+
if (up === cwd) {
10+
throw new Error("no package.json found for this project")
11+
}
12+
cwd = up
913
}
1014
return cwd
1115
}

0 commit comments

Comments
 (0)