Skip to content

Commit

Permalink
Use browseURL() and require rstudioapi in ipums_view() (#62)
Browse files Browse the repository at this point in the history
Co-authored-by: Derek Burk <burkx031@umn.edu>
  • Loading branch information
robe2037 and dtburk committed Oct 17, 2023
1 parent dcd298b commit c7a7ec0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions R/viewer.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ ipums_view <- function(x, out_file = NULL, launch = TRUE) {
htmltools::save_html(html_page, out_file)

if (launch) {
if (requireNamespace("rstudioapi", quietly = TRUE)) {
if (requireNamespace("rstudioapi", quietly = TRUE) && rstudioapi::isAvailable()) {
rstudioapi::viewer(out_file)
} else {
shell.exec(out_file)
rlang::abort(c(
"RStudio and the rstudioapi package are required to use `ipums_view()`",
"i" = "Install rstudioapi with `install.packages(\"rstudioapi\")`"
))
}
invisible(out_file)
} else {
Expand Down
4 changes: 2 additions & 2 deletions R/web_url.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ ipums_website.ipums_ddi <- function(x,
)

if (launch) {
system2("open", url)
utils::browseURL(url)
invisible(url)
} else {
url
Expand Down Expand Up @@ -180,7 +180,7 @@ ipums_website.character <- function(x,
)

if (launch) {
system2("open", url)
utils::browseURL(url)
invisible(url)
} else {
url
Expand Down

0 comments on commit c7a7ec0

Please sign in to comment.