Skip to content

Commit b732fcf

Browse files
authored
Skip stat call / throwing when files don't exist (#225)
1 parent 206e49a commit b732fcf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/filesystem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export interface ReadJsonAsync {
3333
}
3434

3535
export function fileExistsSync(path: string): boolean {
36+
// If the file doesn't exist, avoid throwing an exception over the native barrier for every miss
37+
if (!fs.existsSync(path)) {
38+
return false;
39+
}
3640
try {
3741
const stats = fs.statSync(path);
3842
return stats.isFile();

0 commit comments

Comments
 (0)