diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-04-26 09:26:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 09:26:05 -0400 |
commit | 3c7c5865778360aeb2b1285a414d1f8d878d7a22 (patch) | |
tree | 519dca4c95f37f60f7f5e1dabcdddc5df4515d1e /runtime/ops/spawn.rs | |
parent | dc4ab1d9340a58f81beab24ef211e900acbb9ad8 (diff) |
refactor(ops/process): add `StdioOrRid` enum (#14393)
Diffstat (limited to 'runtime/ops/spawn.rs')
-rw-r--r-- | runtime/ops/spawn.rs | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/runtime/ops/spawn.rs b/runtime/ops/spawn.rs index 196a7eed6..9ec1937af 100644 --- a/runtime/ops/spawn.rs +++ b/runtime/ops/spawn.rs @@ -3,6 +3,7 @@ use super::io::ChildStderrResource; use super::io::ChildStdinResource; use super::io::ChildStdoutResource; +use super::process::Stdio; use crate::permissions::Permissions; use deno_core::error::AnyError; use deno_core::op; @@ -43,22 +44,6 @@ impl Resource for ChildResource { #[derive(Deserialize)] #[serde(rename_all = "camelCase")] -pub enum Stdio { - Inherit, - Piped, - Null, -} - -fn subprocess_stdio_map(s: &Stdio) -> Result<std::process::Stdio, AnyError> { - match s { - Stdio::Inherit => Ok(std::process::Stdio::inherit()), - Stdio::Piped => Ok(std::process::Stdio::piped()), - Stdio::Null => Ok(std::process::Stdio::null()), - } -} - -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] pub struct SpawnArgs { cmd: String, args: Vec<String>, @@ -161,9 +146,9 @@ fn create_command( }); } - command.stdin(subprocess_stdio_map(&args.stdio.stdin)?); - command.stdout(subprocess_stdio_map(&args.stdio.stdout)?); - command.stderr(subprocess_stdio_map(&args.stdio.stderr)?); + command.stdin(args.stdio.stdin.as_stdio()); + command.stdout(args.stdio.stdout.as_stdio()); + command.stderr(args.stdio.stderr.as_stdio()); Ok(command) } |