Skip to content

Commit 50c6c13

Browse files
committed
[rust] Avoid repetition in logic to run powershell or not
1 parent 258d3da commit 50c6c13

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

rust/src/lib.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -448,20 +448,14 @@ pub trait SeleniumManager {
448448
));
449449
let mut browser_version: Option<String> = None;
450450
for driver_version_command in commands.into_iter() {
451-
let output = if driver_version_command.display().starts_with("(Get-") {
452-
match run_powershell_command_with_log(self.get_logger(), driver_version_command) {
453-
Ok(out) => out,
454-
Err(_e) => continue,
455-
}
451+
let command_result = if driver_version_command.display().starts_with("(Get-") {
452+
run_powershell_command_with_log(self.get_logger(), driver_version_command)
456453
} else {
457-
match run_shell_command_with_log(
458-
self.get_logger(),
459-
self.get_os(),
460-
driver_version_command,
461-
) {
462-
Ok(out) => out,
463-
Err(_e) => continue,
464-
}
454+
run_shell_command_with_log(self.get_logger(), self.get_os(), driver_version_command)
455+
};
456+
let output = match command_result {
457+
Ok(out) => out,
458+
Err(_) => continue,
465459
};
466460

467461
let full_browser_version = parse_version(output, self.get_logger()).unwrap_or_default();

0 commit comments

Comments
 (0)