Skip to content

Commit

Permalink
[Patch] Fix potential infinite loop in findPackageJson. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
dumganhar authored Nov 4, 2024
1 parent 14bce7e commit 62588f9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/package/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ function isModuleDir(current: string, moduleDirs: readonly string[]) {
}

export async function findPackageJson(base: string, moduleDirs: readonly string[]) {
const { root } = path.parse(base);
let { root } = path.parse(base);
if (!root) {
root = process.cwd();
}
let current = base;

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

0 comments on commit 62588f9

Please sign in to comment.