Skip to main content

wasm_pack/test/
webdriver.rs

1//! Getting WebDriver client binaries.
2
3mod chromedriver;
4mod geckodriver;
5mod safaridriver;
6
7use crate::PBAR;
8use anyhow::Result;
9use binary_install::Cache;
10use std::path::PathBuf;
11
12pub use self::{
13    chromedriver::{get_or_install_chromedriver, install_chromedriver},
14    geckodriver::{get_or_install_geckodriver, install_geckodriver},
15    safaridriver::get_safaridriver,
16};
17
18// ------ driver helpers  ------
19
20fn get_and_notify(
21    cache: &Cache,
22    installation_allowed: bool,
23    name: &str,
24    url: &str,
25) -> Result<Option<PathBuf>> {
26    if let Some(dl) = cache.download(false, name, &[name], url)? {
27        return Ok(Some(dl.binary(name)?));
28    }
29    if installation_allowed {
30        PBAR.info(&format!("Getting {}...", name));
31    }
32    match cache.download(installation_allowed, name, &[name], url)? {
33        Some(dl) => Ok(Some(dl.binary(name)?)),
34        None => Ok(None),
35    }
36}