Skip to content

Commit 3d471fd

Browse files
committed
allow to disable overwrite of manifest files
1 parent 520d625 commit 3d471fd

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: codecheck
22
Title: Helper Functions for CODECHECK Project
3-
Version: 0.0.0.9009
3+
Version: 0.0.0.9010
44
Authors@R:
55
c(person(given = "Stephen",
66
family = "Eglen",

R/codecheck.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ codecheck_metadata <- function(root = getwd()) {
6161
##' @param metadata - the codecheck metadata list.
6262
##' @param dest_dir - folder where outputs are to be copied to (codecheck/outputs)
6363
##' @param keep_full_path - TRUE to keep relative pathname of figures.
64+
##' @param overwrite - TRUE to overwrite the output files even if they already exist
6465
##' @return A dataframe containing one row per manifest file.
6566
##' @author Stephen Eglen
6667
##' @export
6768
copy_manifest_files <- function(root, metadata, dest_dir,
68-
keep_full_path = FALSE) {
69+
keep_full_path = FALSE,
70+
overwrite = FALSE) {
6971
manifest = metadata$manifest
7072
outputs = sapply(manifest, function(x) x$file)
7173
src_files = file.path(root, outputs)
@@ -87,8 +89,10 @@ copy_manifest_files <- function(root, metadata, dest_dir,
8789
dir.create(dir, recursive=TRUE)
8890
}
8991
}
90-
file.copy(src_files, dest_files, overwrite=TRUE)
91-
dest_files
92+
93+
if (overwrite) message("Overwriting output files: ", toString(dest_files))
94+
file.copy(src_files, dest_files, overwrite = overwrite)
95+
9296
manifest_df = data.frame(output=outputs,
9397
comment=sapply(manifest, function(x) x$comment),
9498
dest=dest_files,

inst/extdata/templates/codecheck/codecheck.Rmd

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ output:
88
---
99

1010
```{r rsetup,eval=TRUE,include=FALSE}
11-
require(codecheck)
12-
require(knitr)
13-
require(rprojroot)
14-
require(yaml)
15-
require(xtable)
16-
require(tibble)
17-
require(readr)
18-
options(width=60)
11+
require("codecheck")
12+
require("knitr")
13+
require("rprojroot")
14+
require("yaml")
15+
require("xtable")
16+
require("tibble")
17+
require("readr")
18+
options(width = 60)
1919
opts_chunk$set(cache=FALSE)
2020
2121
root = find_root("codecheck.yml")
@@ -36,7 +36,9 @@ if ( !dir.exists(dest_dir) ) {
3636
}
3737
3838
manifest_df = copy_manifest_files(root, metadata,
39-
dest_dir, keep_full_path=FALSE)
39+
dest_dir, keep_full_path = FALSE,
40+
overwrite = FALSE,
41+
)
4042
```
4143

4244
---

man/copy_manifest_files.Rd

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)