From 1993ba916d21ed09d3030c8ac5179137abc9c6ca Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 15 Sep 2021 12:18:57 -0400 Subject: [PATCH 1/7] See if using fs::path_home() works on windows --- R/bookdown_to_leanpub.R | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/R/bookdown_to_leanpub.R b/R/bookdown_to_leanpub.R index 23f3807..ad8e6c9 100644 --- a/R/bookdown_to_leanpub.R +++ b/R/bookdown_to_leanpub.R @@ -28,10 +28,7 @@ get_bookdown_spec <- function(path = ".") { bookdown_path <- function(path = ".") { - # See what unzip is being used - operating_system <- Sys.info()[1] - - path <- rprojroot::find_root(rprojroot::has_file("_bookdown.yml"), path = file.path(path)) + path <- fs::path_home("_bookdown.yml") return(path) } From 8877cd6c4972f0c8af4d8e3ac1b15241a23b24b5 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 15 Sep 2021 13:03:42 -0400 Subject: [PATCH 2/7] Need mode = "wb" --- R/example_data.R | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/R/example_data.R b/R/example_data.R index 3b663ad..e2bf1bb 100644 --- a/R/example_data.R +++ b/R/example_data.R @@ -48,18 +48,11 @@ example_repo_setup <- function(dest_dir = ".") { dir.create(dest_dir) } download.file(url = "https://github.com/jhudsl/DaSL_Course_Template_Leanpub/raw/main/example-repo.zip", - destfile = zip_file) + destfile = zip_file, + mode = "wb") - # See what unzip is being used - operating_system <- Sys.info()[1] - message(operating_system) - if (operating_system == "Windows" ){ - # Unzip function doesn't always work for windows - system(paste("7z a -tzip", zip_file, dest_dir)) - } else { - # Unzip the folder - utils::unzip(zip_file, exdir = dest_dir) - } + # Unzip the folder + utils::unzip(zip_file, exdir = dest_dir) } #' Clean up example repo files From c4e14b511553efb5b932ce98d5d0a4ed2854fb2a Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 15 Sep 2021 12:18:57 -0400 Subject: [PATCH 3/7] Revert "See if using fs::path_home() works on windows" This reverts commit 1993ba916d21ed09d3030c8ac5179137abc9c6ca. --- R/bookdown_to_leanpub.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/bookdown_to_leanpub.R b/R/bookdown_to_leanpub.R index ad8e6c9..23f3807 100644 --- a/R/bookdown_to_leanpub.R +++ b/R/bookdown_to_leanpub.R @@ -28,7 +28,10 @@ get_bookdown_spec <- function(path = ".") { bookdown_path <- function(path = ".") { - path <- fs::path_home("_bookdown.yml") + # See what unzip is being used + operating_system <- Sys.info()[1] + + path <- rprojroot::find_root(rprojroot::has_file("_bookdown.yml"), path = file.path(path)) return(path) } From d37b562c6be74c9c584442313466ac660755decc Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 15 Sep 2021 13:44:35 -0400 Subject: [PATCH 4/7] Try zip package --- R/example_data.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/example_data.R b/R/example_data.R index e2bf1bb..d84b76d 100644 --- a/R/example_data.R +++ b/R/example_data.R @@ -36,7 +36,7 @@ bad_quiz_path <- function() { #' @export #' #' @importFrom utils download.file -#' @importFrom utils unzip +#' @importFrom zip unzip #' @examples #' #' example_repo_setup() @@ -52,7 +52,7 @@ example_repo_setup <- function(dest_dir = ".") { mode = "wb") # Unzip the folder - utils::unzip(zip_file, exdir = dest_dir) + zip::unzip(zip_file, exdir = dest_dir) } #' Clean up example repo files From 9c15d4892d0b6532584286b93577c2136209943f Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 15 Sep 2021 13:49:51 -0400 Subject: [PATCH 5/7] add zip to dependency list --- DESCRIPTION | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index c1a3172..b4edb02 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,7 +38,8 @@ Imports: googledrive, yaml, stringr, knitr (>= 1.33), - qpdf + qpdf, + zip Suggests: remotes, testthat From dab0e2d6a6865a99904f84fb0364e8584dba98b6 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 15 Sep 2021 13:53:26 -0400 Subject: [PATCH 6/7] try downloader --- DESCRIPTION | 4 ++-- R/example_data.R | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b4edb02..9cf7282 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -39,10 +39,10 @@ Imports: googledrive, stringr, knitr (>= 1.33), qpdf, - zip Suggests: remotes, - testthat + testthat, + downloader Encoding: UTF-8 LazyData: true Remotes: jhudsl/text2speech, diff --git a/R/example_data.R b/R/example_data.R index d84b76d..099715a 100644 --- a/R/example_data.R +++ b/R/example_data.R @@ -36,7 +36,7 @@ bad_quiz_path <- function() { #' @export #' #' @importFrom utils download.file -#' @importFrom zip unzip +#' @importFrom utils unzip #' @examples #' #' example_repo_setup() @@ -47,12 +47,12 @@ example_repo_setup <- function(dest_dir = ".") { if (!dir.exists(dest_dir)) { dir.create(dest_dir) } - download.file(url = "https://github.com/jhudsl/DaSL_Course_Template_Leanpub/raw/main/example-repo.zip", - destfile = zip_file, - mode = "wb") + downloader::download(url = "https://github.com/jhudsl/DaSL_Course_Template_Leanpub/raw/main/example-repo.zip", + destfile = zip_file, + mode = "wb") # Unzip the folder - zip::unzip(zip_file, exdir = dest_dir) + utils::unzip(zip_file, exdir = dest_dir) } #' Clean up example repo files From 753a36f0f0b7b9b81a21fbf461e613172f9a96cb Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Wed, 15 Sep 2021 13:54:19 -0400 Subject: [PATCH 7/7] Update importFrom --- R/example_data.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/example_data.R b/R/example_data.R index 099715a..818fe0a 100644 --- a/R/example_data.R +++ b/R/example_data.R @@ -35,7 +35,7 @@ bad_quiz_path <- function() { #' @param dest_dir The destination directory you would like the example repo files to be placed. By default is current directory. #' @export #' -#' @importFrom utils download.file +#' @importFrom downloader download #' @importFrom utils unzip #' @examples #'