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 authored and bluwy committed Oct 3, 2023
1 parent 8bc1f9d commit 6f6e5de
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/vite/src/node/server/searchRoot.ts
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 6f6e5de

Please sign in to comment.