Skip to content

Commit

Permalink
Rmd files moved to tmp before knit
Browse files Browse the repository at this point in the history
  • Loading branch information
bburns632 committed May 17, 2024
1 parent cff4610 commit 390434b
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions R/CreatePackageReport.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,28 @@ PackageReport <- R6::R6Class(
, render_report = function() {
log_info("Rendering package report...")

# copy Rmd files to temp directory to avoid writing interim files to package repo
tmp_dir <- tempfile("package_report") # subdir within temp directory
tmp_package_report_rmd <- file.path(tmp_dir, "package_report.Rmd")

orig_package_report_rmd <- system.file(file.path("package_report", "package_report.Rmd"), package = "pkgnet")
orig_files <- list.files(dirname(orig_package_report_rmd), full.names = TRUE)

dir.create(tmp_dir)
file.copy(
from = orig_files,
to = tmp_dir,
recursive = TRUE,
overwrite = TRUE
)

# render report
rmarkdown::render(
input = system.file(
file.path("package_report", "package_report.Rmd")
, package = "pkgnet"
)
input = tmp_package_report_rmd
, output_dir = dirname(self$report_path)
, output_file = basename(self$report_path)
, intermediates_dir = tmp_dir
, knit_root_dir = tmp_dir
, quiet = TRUE
, params = list(
reporters = private$reporters
Expand All @@ -86,6 +101,9 @@ PackageReport <- R6::R6Class(
, sprintf("It is available at %s", self$report_path)
))

# Clean up tmp
unlink(tmp_dir, recursive = TRUE)

# If suppress flag is unset, then env variable will be emptry string ""
if (identical(Sys.getenv("PKGNET_SUPPRESS_BROWSER"), "")) {
utils::browseURL(self$report_path)
Expand Down

0 comments on commit 390434b

Please sign in to comment.