Skip to content

Commit 79c27ea

Browse files
committed
code cleanup
1 parent e264553 commit 79c27ea

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

lib/dsc-lib/src/util.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,16 @@ pub fn canonicalize_which(executable: &str, cwd: Option<&str>) -> Result<String,
239239
if cfg!(target_os = "windows") && executable_path.extension().is_none() {
240240
executable_path.set_extension("exe");
241241
}
242-
let mut executable = executable_path.to_string_lossy().to_string();
243-
if which(&executable).is_err() && !Path::new(&executable).is_absolute() {
242+
if which(executable).is_err() {
244243
if let Some(cwd) = cwd {
245244
let cwd_path = Path::new(cwd);
246-
match canonicalize(cwd_path.join(&executable)) {
247-
Err(_err) => {
248-
return Err(DscError::CommandOperation(t!("util.executableNotFound", executable = &executable, cwd = cwd_path.to_string_lossy()).to_string(), executable.to_string()));
249-
},
250-
Ok(canonical_path) => {
251-
executable = canonical_path.to_string_lossy().to_string();
252-
}
245+
if let Ok(canonical_path) = canonicalize(cwd_path.join(executable)) {
246+
return Ok(canonical_path.to_string_lossy().to_string());
253247
}
254248
}
249+
return Err(DscError::CommandOperation(t!("util.executableNotFound", executable = &executable, cwd = cwd : {:?}).to_string(), executable.to_string()));
255250
}
256-
Ok(executable)
251+
Ok(executable.to_string())
257252
}
258253

259254
#[macro_export]

0 commit comments

Comments
 (0)