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 07258ff
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.ts
Expand Up @@ -243,8 +243,9 @@ function removeQuerystring(id: string) {

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

0 comments on commit 07258ff

Please sign in to comment.