Skip to content

Commit

Permalink
Skip stat call / throwing when files don't exist (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
robstolarz committed Nov 30, 2022
1 parent 206e49a commit b732fcf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/filesystem.ts
Expand Up @@ -33,6 +33,10 @@ export interface ReadJsonAsync {
}

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

0 comments on commit b732fcf

Please sign in to comment.