From bc9fb8e302623488b5507a406e849a00a704bba0 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Mon, 9 Oct 2023 19:45:36 +0800 Subject: [PATCH] format [no ci] --- shared/src/fns.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/shared/src/fns.rs b/shared/src/fns.rs index 3ebcf268..5c9e1e83 100644 --- a/shared/src/fns.rs +++ b/shared/src/fns.rs @@ -7,23 +7,28 @@ use crate::Url; pub fn expand_path(p: impl AsRef) -> PathBuf { let mut p = p.as_ref(); - // expand the environment variable by calling the "echo" command, in linux case, this also expands the '~' path + // expand the environment variable by calling the "echo" command, in linux case, + // this also expands the '~' path #[cfg(target_os = "windows")] let expanded_path = match std::process::Command::new("cmd").args(&["/C", "echo"]).arg(p).output() { - Ok(output) if output.status.success() => Some(String::from_utf8_lossy(&output.stdout) - .trim_end() - .trim_matches('"') - .replace("\\\"", "\"") - .to_string() - ), + Ok(output) if output.status.success() => Some( + String::from_utf8_lossy(&output.stdout) + .trim_end() + .trim_matches('"') + .replace("\\\"", "\"") + .to_string(), + ), _ => None, }; #[cfg(not(target_os = "windows"))] let expanded_path = match std::process::Command::new("sh") - .arg("-c") - .arg(format!("echo \"{}\"", p.to_string_lossy().replace("\"", "\\\""))) - .output() { - Ok(output) if output.status.success() => Some(String::from_utf8_lossy(&output.stdout).trim_end().to_string()), + .arg("-c") + .arg(format!("echo \"{}\"", p.to_string_lossy().replace("\"", "\\\""))) + .output() + { + Ok(output) if output.status.success() => { + Some(String::from_utf8_lossy(&output.stdout).trim_end().to_string()) + } _ => None, }; @@ -168,12 +173,11 @@ pub fn optional_bool(s: &str) -> Option { #[cfg(test)] mod tests { - use std::{borrow::Cow, path::Path, env}; + use std::{borrow::Cow, env, path::Path}; + use super::path_relative_to; use crate::expand_path; -use super::path_relative_to; - #[cfg(unix)] #[test] fn test_path_relative_to() {