Skip to content

Commit

Permalink
refactor(libs/cli): create_child
Browse files Browse the repository at this point in the history
  • Loading branch information
a-wing committed Nov 5, 2024
1 parent 6a53657 commit 0215b33
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions libs/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ pub fn get_codec_type(codec: &RTCRtpCodecCapability) -> RTPCodecType {
}

pub fn create_child(command: Option<String>) -> Result<Option<Mutex<Child>>> {
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,
})
}

0 comments on commit 0215b33

Please sign in to comment.