From bbd48e37ce78e2bf54b085df602cce311bb5e324 Mon Sep 17 00:00:00 2001 From: HDash <16350928+HDash@users.noreply.github.com> Date: Wed, 6 Nov 2024 21:08:38 +0000 Subject: [PATCH] Fix `download_button()` error when `downloadthis` package is not available --- DESCRIPTION | 2 +- NEWS.md | 7 +++++++ R/download_button.R | 4 +++- R/utilities.R | 5 ++++- man/check_dep.Rd | 3 ++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8907ee9..2181bfc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: MotifPeeker Title: Benchmarking Epigenomic Profiling Methods Using Motif Enrichment -Version: 0.99.8 +Version: 0.99.9 Authors@R: c( person(given = "Hiranyamaya", family = "Dash", diff --git a/NEWS.md b/NEWS.md index 29bf17e..32f94d7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# MotifPeeker 0.99.9 + +## Bug Fixes + +* Fix `download_button()` error when `downloadthis` package is not available. + + # MotifPeeker 0.99.8 ## Miscellaneous diff --git a/R/download_button.R b/R/download_button.R index 7eef6ce..4e15989 100644 --- a/R/download_button.R +++ b/R/download_button.R @@ -32,7 +32,9 @@ download_button <- function(path, wrn_msg <- paste("Package", shQuote("downloadthis"), "is required to", "add download buttons to the HTML report. Skipping", "download buttons...") - check_dep("downloadthis", fatal = FALSE, custom_msg = wrn_msg) + if (!check_dep("downloadthis", fatal = FALSE, custom_msg = wrn_msg)) { + return(NULL) + } btn_args <- list( path = path, diff --git a/R/utilities.R b/R/utilities.R index 521f86f..f998933 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -160,7 +160,8 @@ check_duplicates <- function(x) { #' package is not attached. #' @param custom_msg a custom message to display if the package is not attached. #' -#' @returns Null +#' @returns TRUE if the package is available or else FALSE if +#' \code{fatal = FALSE}. #' #' @keywords internal check_dep <- function(pkg, fatal = TRUE, custom_msg = NULL){ @@ -173,8 +174,10 @@ check_dep <- function(pkg, fatal = TRUE, custom_msg = NULL){ stop(custom_msg) } else { warning(custom_msg) + return(FALSE) } } + return(TRUE) } #' Stop if MEME suite is not installed diff --git a/man/check_dep.Rd b/man/check_dep.Rd index c838607..acf7b7f 100644 --- a/man/check_dep.Rd +++ b/man/check_dep.Rd @@ -15,7 +15,8 @@ package is not attached.} \item{custom_msg}{a custom message to display if the package is not attached.} } \value{ -Null +TRUE if the package is available or else FALSE if +\code{fatal = FALSE}. } \description{ Stop execution if a package is not attached.