Skip to content

Commit

Permalink
using with_dir instead of manually changing working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
DouglasMesquita committed Dec 18, 2023
1 parent 8085b14 commit 24259e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Suggests:
spelling
Imports:
dplyr,
fs,
ggplot2,
glue,
jsonlite,
Expand All @@ -40,5 +41,5 @@ Imports:
shinytest2,
stringr,
testthat,
fs
withr
Language: en-US
23 changes: 12 additions & 11 deletions R/utils_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ combine_performances <- function(performance_list) {
#' time and test name
#' @param file name of the file to which the report should be saved (.html)
#'
#' @return None. This function is called for side effects
#'
#' @importFrom quarto quarto_render
#' @export
create_report <- function(report_params, file = NULL) {
Expand All @@ -50,17 +52,16 @@ create_report <- function(report_params, file = NULL) {
report_template_file <- basename(report_template_file)

# generate HTML
# move work directory in order to run quarto
wb <- getwd()
on.exit(expr = {
setwd(dir = wb)
})

setwd(dir = report_dir)
quarto_render(
input = report_template_file,
output_file = report_file,
execute_params = report_params
# execute order in the destination
with_dir(
new = report_dir,
code = {
quarto_render(
input = report_template_file,
output_file = report_file,
execute_params = report_params
)
}
)
}

Expand Down
3 changes: 3 additions & 0 deletions man/create_report.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 24259e1

Please sign in to comment.