Skip to content

Commit

Permalink
fix: handle errors during hasWorkspacePackageJSON function (#14394)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Sep 18, 2023
1 parent 9884308 commit c3e4791
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/vite/src/node/server/searchRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ function hasWorkspacePackageJSON(root: string): boolean {
if (!isFileReadable(path)) {
return false
}
const content = JSON.parse(fs.readFileSync(path, 'utf-8')) || {}
return !!content.workspaces
try {
const content = JSON.parse(fs.readFileSync(path, 'utf-8')) || {}
return !!content.workspaces
} catch {
return false
}
}

function hasRootFile(root: string): boolean {
Expand Down

0 comments on commit c3e4791

Please sign in to comment.