Skip to content

Commit

Permalink
Remove intermediate dir when roborazzi.deleteOldScreenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirom committed Nov 4, 2024
1 parent acfc5d5 commit 4918281
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ abstract class RoborazziPlugin : Plugin<Project> {
test = test,
roborazziProperties = roborazziProperties,
outputDir = outputDir,
intermediateDir = intermediateDir,
roborazziResults = roborazziResults,
)

Expand Down Expand Up @@ -558,10 +559,18 @@ abstract class RoborazziPlugin : Plugin<Project> {
test: AbstractTestTask,
roborazziProperties: Map<String, Any?>,
outputDir: DirectoryProperty,
intermediateDir: DirectoryProperty,
roborazziResults: CaptureResults,
) {
if (roborazziProperties["roborazzi.deleteOldScreenshots"] == "true") {
// Remove all files not in the results
// Delete all images from the intermediateDir
intermediateDir.get().asFile.walkTopDown().forEach { file ->
if (KnownImageFileExtensions.contains(file.extension)) {
file.delete()
}
}

// Remove all files not in the results from the outputDir
val removingFiles: MutableSet<String> = outputDir.get().asFile
.listFiles()
?.toList()
Expand Down

0 comments on commit 4918281

Please sign in to comment.