From 2ea95ae1130ef1aa588fa32c89995aa545cccdb3 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Thu, 7 Dec 2023 14:34:19 -0800 Subject: [PATCH] Add on.exit() to render() Remove tmp- files --- DESCRIPTION | 2 +- NEWS.md | 7 +++++++ R/render.R | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 55d8cd6a..868ad00f 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: csasdown Title: Reproducible CSAS Reports with Bookdown -Version: 0.1.2 +Version: 0.1.3 Authors@R: c(person(given = c("Sean", "C."), family = "Anderson", diff --git a/NEWS.md b/NEWS.md index 916f8e93..cbbb9ec5 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,12 @@ # csasdown +# csasdown 0.1.3 + +* Add `on.exit()` to `csasdown::render()` to avoid leaving behind `tmp-` files + if an R error is encountered. + +* Fix `csasdown::render()` render environment. + # csasdown 0.1.2 * The Science Response template now uses `french_title` instead of `title_other` diff --git a/R/render.R b/R/render.R index 70e5b3c6..d1d663c3 100644 --- a/R/render.R +++ b/R/render.R @@ -73,6 +73,7 @@ render <- function(yaml_fn = "_bookdown.yml", tmp_yaml_rmd_fns <- create_tmp_yaml_rmd_files(yaml_fn, verbose) tmp_yaml_fn <- tmp_yaml_rmd_fns[[1]] tmp_rmd_fns <- tmp_yaml_rmd_fns[[2]] + on.exit(unlink(unlist(tmp_yaml_rmd_fns), force = TRUE)) index_fn <- get_index_filename(tmp_yaml_fn, verbose) set_render_type(index_fn, "asis")