1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
mod chromedriver;
mod geckodriver;
pub mod installer;
use eyre::Result;
pub use installer::Driver;
use url::Url;
#[doc(hidden)]
pub trait DriverFetcher {
const BASE_URL: &'static str;
fn latest_version(&self) -> Result<String>;
fn direct_download_url(&self, version: &str) -> Result<Url>;
}
#[must_use]
#[cfg(target_os = "windows")]
fn run_powershell_cmd(cmd: &str) -> std::process::Output {
use std::process::{Command, Stdio};
use tracing::debug;
let mut ps = Command::new("powershell");
ps.stdin(Stdio::piped());
ps.stdout(Stdio::piped());
ps.stderr(Stdio::piped());
let process = ps.args(&["-Command", cmd]).spawn().unwrap();
let output = process
.wait_with_output()
.expect("failed to wait on child process");
debug!(
"stdout: {:?}",
String::from_utf8(output.clone().stdout).unwrap()
);
debug!(
"stderr: {:?}",
String::from_utf8(output.clone().stderr).unwrap()
);
output
}