diff --git a/R/codemeta_readme.R b/R/codemeta_readme.R index 6056e018..c3f7a050 100644 --- a/R/codemeta_readme.R +++ b/R/codemeta_readme.R @@ -47,7 +47,16 @@ get_pkg_name <- function(entry) { url_onboarded_json <- "https://badges.ropensci.org/json/onboarded.json" - reviews <- jsonlite::read_json(url_onboarded_json) + reviews <- suppressWarnings( + try(jsonlite::read_json(url_onboarded_json), + silent = TRUE)) + + if (is(reviews, "try-error")) { + return(tibble::tibble( + review = 0, + package = "Nope" + )) + } tibble::tibble( review = purrr::map_dbl(reviews, "iss_no"), diff --git a/R/create_codemeta.R b/R/create_codemeta.R index b665a207..4172d047 100644 --- a/R/create_codemeta.R +++ b/R/create_codemeta.R @@ -25,6 +25,12 @@ create_codemeta <- function( ... ) { + if (!pingr::is_online()) { + if (verbose) { + message("Your computer is not online. codemetar will find less metadata than if it were.") + } + } + ## looks like we got a package name/path or Description file if (is.character(pkg)) { diff --git a/R/guess_provider.R b/R/guess_provider.R index 23f5c8d0..ab98c7ed 100644 --- a/R/guess_provider.R +++ b/R/guess_provider.R @@ -6,13 +6,15 @@ ## cache available packages .CRAN <- function() { - available_source_packages("https://cran.rstudio.com") + suppressWarnings( + available_source_packages("https://cran.rstudio.com")) } # .BIOC ------------------------------------------------------------------------ .BIOC <- function() { - available_source_packages("https://www.bioconductor.org/packages/release/bioc") + suppressWarnings( + available_source_packages("https://www.bioconductor.org/packages/release/bioc")) } # CRAN ------------------------------------------------------------------------- diff --git a/R/utils.R b/R/utils.R index 27313b90..bd2144e2 100644 --- a/R/utils.R +++ b/R/utils.R @@ -117,6 +117,11 @@ get_url_status_code <- function(url) { # check_urls ------------------------------------------------------------------- check_urls <- function(urls) { + if (!pingr::is_online()) { + + return("") + } + messages <- do.call(rbind, lapply(urls, get_url_status_code)) failed <- (messages$message != "All good")