Skip to content

Commit

Permalink
updates approach to dealing with no chromium browser available
Browse files Browse the repository at this point in the history
  • Loading branch information
francojc committed Aug 17, 2024
1 parent 277a116 commit 6f5e7f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions R/write_kbl.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ write_kbl <-
if (device %in% c("html", "pdf", "png", "jpeg")) {
browser_path <- check_chromium_browser()
if (!is.null(browser_path)) {
# Set the path to the browser
options(chromote.browser_path = browser_path)
if (file.exists(browser_path)) {
# Set the path to the browser
options(chromote.browser_path = browser_path)
} else {
stop("The detected browser path does not exist: ", browser_path)
}
} else {
msg <- paste0("A Chromium-based browser (e.g., Google Chrome, ",
"Chromium, Microsoft Edge, or Brave) is required on your system ",
Expand Down Expand Up @@ -150,6 +154,5 @@ check_chromium_browser <- function() {
if (chrome_env != "" && file.exists(chrome_env)) {
return(chrome_env)
}

return(NULL)
}
5 changes: 3 additions & 2 deletions tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ cleanup_crashpad <- function() {
testthat::setup(cleanup_crashpad)
testthat::teardown(cleanup_crashpad)

# Function to check if Chromium is available
# Function to check if Chromium is
# available and can be initialized
is_chromium_available <- function() {
tryCatch({
chromote::find_chrome()
chromote::Chromote$new()
TRUE
}, error = function(e) {
FALSE
Expand Down

0 comments on commit 6f5e7f5

Please sign in to comment.