Skip to content

Commit 07258ff

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

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: src/index.ts

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

244244
const isFile = (path?: string | undefined): path is string => {
245245
try {
246-
return !!path && fs.statSync(path).isFile()
246+
return !!(path && fs.statSync(path, { throwIfNoEntry: false })?.isFile())
247247
} catch {
248+
// Node 12 does not support throwIfNoEntry.
248249
return false
249250
}
250251
}

0 commit comments

Comments
 (0)