Skip to content

Commit

Permalink
refactor: simplify copying of temp biocbook folder
Browse files Browse the repository at this point in the history
  • Loading branch information
js2264 committed Oct 5, 2023
1 parent 9ed60bf commit 2af9fe8
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,11 @@ init <- function(
## Move files from temp folder to `new_package` folder
repo <- new_package
dir.create(repo)
d <- list.dirs(tmpdir, full.names = TRUE, recursive = TRUE)
d <- d[dirname(d) != '.']
pattern <- file.path(tmpdir, basename(d)[dirname(dirname(d)) == '.'])
d <- d[dirname(dirname(d)) != '.']
f <- list.files(
tmpdir,
all.files = TRUE, full.names = TRUE, recursive = TRUE
content <- list.files(
file.path(tmpdir, 'BiocBook.template'),
all.files=TRUE, full.names=TRUE, no..=TRUE
)
f <- f[!grepl("archive.zip$", f)]
for (.d in d) dir.create(gsub(pattern, repo, .d))
for (.f in f) file.copy(from = .f, to = gsub(pattern, repo, .f))
unlink(tmpdir, recursive = TRUE)
file.copy(content, repo, recursive=TRUE)
cli::cli_alert_success(cli::col_grey(
"New local book `{repo}` successfully created"
))
Expand Down Expand Up @@ -312,4 +305,3 @@ init <- function(
invisible(BiocBook(repo))

}

0 comments on commit 2af9fe8

Please sign in to comment.