Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: don't require output dirs to exist when cleaning #872

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/modules/directoryCleaner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ export default class DirectoryCleaner extends Module {

this.progressBar.logInfo('cleaning files in output');
await this.progressBar.setSymbol(ProgressBarSymbol.SEARCHING);
await this.progressBar.reset(dirsToClean.length);
await this.progressBar.reset(0);

// If there is nothing to clean, then don't do anything
const filesToClean = await this.options.scanOutputFilesWithoutCleanExclusions(
dirsToClean,
filesToExclude,
async (increment) => {
await this.progressBar.incrementTotal(increment);
},
);
if (filesToClean.length === 0) {
this.progressBar.logDebug('no files to clean');
Expand Down
3 changes: 2 additions & 1 deletion src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ export default class Options implements OptionsProps {
async scanOutputFilesWithoutCleanExclusions(
outputDirs: string[],
writtenFiles: File[],
walkCallback?: FsWalkCallback,
): Promise<string[]> {
// Written files that shouldn't be cleaned
const writtenFilesNormalized = new Set(writtenFiles
Expand All @@ -796,7 +797,7 @@ export default class Options implements OptionsProps {
const cleanExcludedFilesNormalized = new Set((await this.scanCleanExcludeFiles())
.map((filePath) => path.normalize(filePath)));

return (await Options.scanPaths(outputDirs))
return (await Options.scanPaths(outputDirs, walkCallback, false))
.map((filePath) => path.normalize(filePath))
.filter((filePath) => !writtenFilesNormalized.has(filePath))
.filter((filePath) => !cleanExcludedFilesNormalized.has(filePath));
Expand Down
Loading