Skip to content

Commit 62588f9

Browse files
authored
[Patch] Fix potential infinite loop in findPackageJson. (#1)
1 parent 14bce7e commit 62588f9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/package/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ function isModuleDir(current: string, moduleDirs: readonly string[]) {
99
}
1010

1111
export async function findPackageJson(base: string, moduleDirs: readonly string[]) {
12-
const { root } = path.parse(base);
12+
let { root } = path.parse(base);
13+
if (!root) {
14+
root = process.cwd();
15+
}
1316
let current = base;
1417

1518
while (current !== root && !isModuleDir(current, moduleDirs)) {

0 commit comments

Comments
 (0)