From 0215b33e45ee4283b12a969c7f8e52c48c409c49 Mon Sep 17 00:00:00 2001 From: a-wing <1@233.email> Date: Tue, 5 Nov 2024 16:52:31 +0800 Subject: [PATCH] refactor(libs/cli): create_child --- libs/cli/src/lib.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libs/cli/src/lib.rs b/libs/cli/src/lib.rs index 4d8c980..296c003 100644 --- a/libs/cli/src/lib.rs +++ b/libs/cli/src/lib.rs @@ -132,21 +132,21 @@ pub fn get_codec_type(codec: &RTCRtpCodecCapability) -> RTPCodecType { } pub fn create_child(command: Option) -> Result>> { - let child = if let Some(command) = command { - let command = command.replace('\\', "/"); - let mut args = shellwords::split(&command)?; + Ok(match command { + Some(command) => { + #[cfg(windows)] + let command = command.replace('\\', "/"); - Some(Mutex::new( - Command::new(args.remove(0)) - .args(args) - .stdin(Stdio::inherit()) - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()) - .spawn()?, - )) - } else { - None - }; - - Ok(child) + let mut args = shellwords::split(&command)?; + Some(Mutex::new( + Command::new(args.remove(0)) + .args(args) + .stdin(Stdio::inherit()) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .spawn()?, + )) + } + None => None, + }) }