diff --git a/index.js b/index.js index 735aabe..472b93c 100644 --- a/index.js +++ b/index.js @@ -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) { @@ -85,10 +87,12 @@ 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; @@ -96,12 +100,6 @@ module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgres 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;