Skip to content

Commit

Permalink
chore: simplify isFileReadable
Browse files Browse the repository at this point in the history
  • Loading branch information
Demivan committed Feb 13, 2022
1 parent 7994e77 commit 4a43081
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,12 @@ export function writeFile(
* unnecessary in the first place)
*/
export function isFileReadable(filename: string): boolean {
let stat = null
try {
stat = fs.statSync(filename, { throwIfNoEntry: false })
const stat = fs.statSync(filename, { throwIfNoEntry: false })
return !!stat
} catch (e) {
if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false

throw e
return false
}
return !!stat
}

/**
Expand Down

0 comments on commit 4a43081

Please sign in to comment.