We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9d38a7a commit 915f706Copy full SHA for 915f706
post.js
@@ -39,16 +39,20 @@ async function main() {
39
}
40
41
async function totalSize(p) {
42
- const stat = await fs.stat(p);
43
- if (stat.isFile()) return stat.size;
44
- if (stat.isDirectory()) {
45
- let total = 0;
46
- for (const entry of await fs.readdir(p)) {
47
- total += await totalSize(path.join(p, entry));
+ try {
+ const stat = await fs.stat(p);
+ if (stat.isFile()) return stat.size;
+ if (stat.isDirectory()) {
+ let total = 0;
+ for (const entry of await fs.readdir(p)) {
48
+ total += await totalSize(path.join(p, entry));
49
+ }
50
+ return total;
51
- return total;
52
+ return 0;
53
+ } catch {
54
55
- return 0;
56
57
58
async function rmDirContents(dir) {
0 commit comments