Skip to content

Commit d112e36

Browse files
committed
perf: use throwIfNoEntry on Node 14+
1 parent ede9893 commit d112e36

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,10 @@ function removeQuerystring(id: string) {
243243

244244
const isFile = (path?: string | undefined): path is string => {
245245
try {
246-
return !!path && fs.statSync(path).isFile()
246+
if (!path) return false
247+
return fs.statSync(path, { throwIfNoEntry: false })?.isFile() || false
247248
} catch {
249+
// Node 12 does not support throwIfNoEntry.
248250
return false
249251
}
250252
}

0 commit comments

Comments
 (0)