Skip to content

Commit c84ea25

Browse files
committed
[rust] Avoid repetition in logic to run powershell or not
1 parent 3974c4d commit c84ea25

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
@@ -444,20 +444,14 @@ pub trait SeleniumManager {
444444
));
445445
let mut browser_version: Option<String> = None;
446446
for driver_version_command in commands.into_iter() {
447-
let output = if driver_version_command.display().starts_with("(Get-") {
448-
match run_powershell_command_with_log(self.get_logger(), driver_version_command) {
449-
Ok(out) => out,
450-
Err(_e) => continue,
451-
}
447+
let command_result = if driver_version_command.display().starts_with("(Get-") {
448+
run_powershell_command_with_log(self.get_logger(), driver_version_command)
452449
} else {
453-
match run_shell_command_with_log(
454-
self.get_logger(),
455-
self.get_os(),
456-
driver_version_command,
457-
) {
458-
Ok(out) => out,
459-
Err(_e) => continue,
460-
}
450+
run_shell_command_with_log(self.get_logger(), self.get_os(), driver_version_command)
451+
};
452+
let output = match command_result {
453+
Ok(out) => out,
454+
Err(_) => continue,
461455
};
462456

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

0 commit comments

Comments
 (0)