fork of https://github.com/rustwasm/wasm-pack for the needs of NextGraph.org
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
//! Getting WebDriver client binaries.
|
|
|
|
mod chromedriver;
|
|
mod geckodriver;
|
|
mod safaridriver;
|
|
|
|
use binary_install::Cache;
|
|
use failure;
|
|
use std::path::PathBuf;
|
|
use PBAR;
|
|
|
|
pub use self::{
|
|
chromedriver::{get_or_install_chromedriver, install_chromedriver},
|
|
geckodriver::{get_or_install_geckodriver, install_geckodriver},
|
|
safaridriver::get_safaridriver,
|
|
};
|
|
|
|
// ------ driver helpers ------
|
|
|
|
fn get_and_notify(
|
|
cache: &Cache,
|
|
installation_allowed: bool,
|
|
name: &str,
|
|
url: &str,
|
|
) -> Result<Option<PathBuf>, failure::Error> {
|
|
if let Some(dl) = cache.download(false, name, &[name], &url)? {
|
|
return Ok(Some(dl.binary(name)?));
|
|
}
|
|
if installation_allowed {
|
|
PBAR.info(&format!("Getting {}...", name));
|
|
}
|
|
match cache.download(installation_allowed, name, &[name], &url)? {
|
|
Some(dl) => Ok(Some(dl.binary(name)?)),
|
|
None => Ok(None),
|
|
}
|
|
}
|
|
|
|
struct Collector(Vec<u8>);
|
|
|
|
impl curl::easy::Handler for Collector {
|
|
fn write(&mut self, data: &[u8]) -> Result<usize, curl::easy::WriteError> {
|
|
self.0.extend_from_slice(data);
|
|
Ok(data.len())
|
|
}
|
|
}
|
|
|