Skip to content

Commit 04215f9

Browse files
committed
Add a cleaning resource function
1 parent 9fa5a74 commit 04215f9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/testthat/helpers.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ local_quarto_project <- function(
9191
return(file.path(path_tmp, name))
9292
}
9393

94+
local_clean_resources <- function(where, .env = parent.frame()) {
95+
skip_if_not_installed("withr")
96+
skip_if_not_installed("fs")
97+
# clean up output file
98+
files <- fs::dir_ls(where, type = "directory", glob = "*_files")
99+
fs::dir_delete(files)
100+
}
101+
94102
.render <- function(
95103
input,
96104
output_file = NULL,
@@ -103,6 +111,7 @@ local_quarto_project <- function(
103111
skip_if_not_installed("withr")
104112
# work inside input directory
105113
withr::local_dir(dirname(input))
114+
local_clean_resources(where = ".", .env = .env)
106115
output_file_forced <- NULL
107116
if (is.null(output_file)) {
108117
output_file_forced <- basename(withr::local_file(
@@ -116,6 +125,7 @@ local_quarto_project <- function(
116125
output_file_forced
117126
)
118127
}
128+
119129
expect_no_error(quarto_render(
120130
basename(input),
121131
output_file = output_file,

0 commit comments

Comments
 (0)