Skip to content

Commit

Permalink
Fix deletedCount
Browse files Browse the repository at this point in the history
  • Loading branch information
hanquliu committed May 17, 2022
1 parent c12fddd commit a118135
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgres
});
}

const mapper = async (file, fileIndex) => {
let deletedCount = 0;

const mapper = async file => {
file = path.resolve(cwd, file);

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

deletedCount += 1;

onProgress({
totalCount: files.length,
deletedCount: fileIndex,
percent: fileIndex / files.length
deletedCount,
percent: deletedCount / files.length
});

return file;
};

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

onProgress({
totalCount: files.length,
deletedCount: files.length,
percent: 1
});

removedFiles.sort((a, b) => a.localeCompare(b));

return removedFiles;
Expand Down

0 comments on commit a118135

Please sign in to comment.