Skip to content

Commit

Permalink
Make skip_if_offline() more robust by checking multiple hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
jdblischak committed Oct 27, 2023
1 parent f5c71bb commit 1615b4e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions R/skip.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,19 @@ package_version <- function(x) {

#' @export
#' @rdname skip
skip_if_offline <- function(host = "r-project.org") {
skip_if_offline <- function(host = c("r-project.org", "github.com", "captive.apple.com")) {
skip_on_cran()
check_installed("curl")

skip_if_not(has_internet(host), "offline")
}
has_internet <- function(host) {
!is.null(curl::nslookup(host, error = FALSE))
for (h in host) {
if (!is.null(curl::nslookup(h, error = FALSE))) {
return(TRUE)
}
}
return(FALSE)
}

#' @export
Expand Down

0 comments on commit 1615b4e

Please sign in to comment.