-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't try to detect the browser version (#39)
* don't try to find the browser version * rename find_browser_and_version.R * remove scripts * move tests
- Loading branch information
1 parent
c79ca82
commit 2c8b914
Showing
8 changed files
with
114 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Tries to find a browser that we can use | ||
find_browser <- function() { # nolint: cyclocomp_linter | ||
if (is_mac()) { | ||
path <- "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" | ||
|
||
if (file.exists(path)) { | ||
return("chrome") | ||
} else { | ||
find_browser_linux() | ||
} | ||
} else if (is_windows()) { | ||
find_browser_windows() | ||
} else if (is_linux()) { | ||
find_browser_linux() | ||
} | ||
} | ||
|
||
find_browser_linux <- function() { | ||
possible_names <- c( | ||
"google-chrome", | ||
"google-chrome-stable", | ||
"chromium-browser", | ||
"chromium", | ||
"google-chrome-beta", | ||
"google-chrome-unstable", | ||
"chrome" | ||
) | ||
|
||
for (path in possible_names) { | ||
path <- Sys.which(path) | ||
if (nzchar(path)) { | ||
return("chrome") | ||
} | ||
} | ||
|
||
path <- Sys.which("firefox") | ||
|
||
if (nzchar(path)) { | ||
"firefox" | ||
} else { | ||
NULL | ||
} | ||
} | ||
|
||
find_browser_windows <- function() { | ||
path <- tryCatch( | ||
{ | ||
path <- utils::readRegistry( | ||
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\chrome.exe\\" | ||
) | ||
path[["(Default)"]] | ||
}, | ||
error = function(e) { | ||
NULL | ||
} | ||
) | ||
|
||
if (!is.null(path)) { | ||
return("chrome") | ||
} | ||
|
||
path <- tryCatch( | ||
{ | ||
path <- utils::readRegistry( | ||
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\firefox.exe\\" | ||
) | ||
path[["(Default)"]] | ||
}, | ||
error = function(e) { | ||
NULL | ||
} | ||
) | ||
|
||
if (!is.null(path)) { | ||
return("firefox") | ||
} | ||
|
||
batch_file <- | ||
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\iexplore.exe\\" | ||
|
||
path <- tryCatch( | ||
{ | ||
path <- utils::readRegistry( | ||
batch_file | ||
) | ||
path[["(Default)"]] | ||
}, | ||
error = function(e) { | ||
NULL | ||
} | ||
) | ||
|
||
if (!is.null(path)) { | ||
return("internet explorer") | ||
} else { | ||
NULL | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.