Skip to content

Commit

Permalink
perf: use throwIfNoEntry on Node 14+
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxinyanc committed Sep 7, 2022
1 parent ede9893 commit d112e36
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.ts
Expand Up @@ -243,8 +243,10 @@ function removeQuerystring(id: string) {

const isFile = (path?: string | undefined): path is string => {
try {
return !!path && fs.statSync(path).isFile()
if (!path) return false
return fs.statSync(path, { throwIfNoEntry: false })?.isFile() || false
} catch {
// Node 12 does not support throwIfNoEntry.
return false
}
}
Expand Down

0 comments on commit d112e36

Please sign in to comment.