Skip to content

Commit

Permalink
perf: improve isFileReadable performance (#6868)
Browse files Browse the repository at this point in the history
  • Loading branch information
Demivan committed Feb 13, 2022
1 parent 78e84c8 commit 62cbe68
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/utils.ts
Expand Up @@ -422,8 +422,8 @@ export function writeFile(
*/
export function isFileReadable(filename: string): boolean {
try {
fs.accessSync(filename, fs.constants.R_OK)
return true
const stat = fs.statSync(filename, { throwIfNoEntry: false })
return !!stat
} catch {
return false
}
Expand Down

0 comments on commit 62cbe68

Please sign in to comment.