Skip to content

Commit

Permalink
fix: handle errors during searchFor* functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Sep 17, 2023
1 parent 1c03172 commit 2eb7a9c
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 2eb7a9c

Please sign in to comment.