Skip to content

Commit 7b4c881

Browse files
authoredMay 24, 2022
Fix ProgressData#deletedCount (#142)
1 parent c12fddd commit 7b4c881

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed
 

‎index.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgres
7474
});
7575
}
7676

77-
const mapper = async (file, fileIndex) => {
77+
let deletedCount = 0;
78+
79+
const mapper = async file => {
7880
file = path.resolve(cwd, file);
7981

8082
if (!force) {
@@ -85,23 +87,19 @@ module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgres
8587
await rimrafP(file, rimrafOptions);
8688
}
8789

90+
deletedCount += 1;
91+
8892
onProgress({
8993
totalCount: files.length,
90-
deletedCount: fileIndex,
91-
percent: fileIndex / files.length
94+
deletedCount,
95+
percent: deletedCount / files.length
9296
});
9397

9498
return file;
9599
};
96100

97101
const removedFiles = await pMap(files, mapper, options);
98102

99-
onProgress({
100-
totalCount: files.length,
101-
deletedCount: files.length,
102-
percent: 1
103-
});
104-
105103
removedFiles.sort((a, b) => a.localeCompare(b));
106104

107105
return removedFiles;

‎readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ await del(patterns, {
127127

128128
```js
129129
{
130-
totalFiles: number,
131-
deletedFiles: number,
130+
totalCount: number,
131+
deletedCount: number,
132132
percent: number
133133
}
134134
```

0 commit comments

Comments
 (0)
Please sign in to comment.