Skip to content

Commit

Permalink
Adapt custom template copying to handle argument missing file name
Browse files Browse the repository at this point in the history
  • Loading branch information
tynsci authored and eager_chatterjee committed May 25, 2023
1 parent ad6a8cb commit 3a06bc3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions R/pmx-report.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,18 @@ pmx_draft <- function(ctr, name, template, edit) {
overwrite = TRUE,
recursive = TRUE
)
# Determine source of template file (variable may be a directory or a file)
template_source <-
if(grepl("\\.[A-z]{2,}$", template)) {
template
} else {
file.path(template, "skeleton", "skeleton.Rmd")
}

file.copy(
from = file.path(template), to = file.path(
skeleton_dir,
"skeleton.Rmd"
), overwrite = TRUE,
recursive = TRUE
from = template_source,
to = file.path(skeleton_dir, "skeleton.Rmd"),
overwrite = TRUE
)
})

Expand Down

0 comments on commit 3a06bc3

Please sign in to comment.