-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 fix(core): Treat empty cache dirs as noise
- Loading branch information
1 parent
9d94362
commit 4d81dd6
Showing
4 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import fs from 'fs-extra' | ||
|
||
export async function isDirEmpty(dirPath: string) { | ||
const files = await fs.readdir(dirPath) | ||
try { | ||
const files = await fs.readdir(dirPath) | ||
|
||
return files.length === 0 | ||
return files.length === 0 | ||
} catch (e) { | ||
if (e instanceof Error && e.message.includes('ENOENT')) { | ||
return true | ||
} | ||
|
||
throw e | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters