summaryrefslogtreecommitdiff
path: root/cli/ops.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-06-22 01:00:14 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-06-21 16:00:14 -0700
commit642eaf97c67c6070935a2977014c743ba59deff8 (patch)
treee31a30799762aa72439185f0e7ece6151210084e /cli/ops.rs
parenteb93dc58a11d9e9a295eff31f9c2c6a3a4c5170b (diff)
feat: redirect process stdio to file (#2554)
Diffstat (limited to 'cli/ops.rs')
-rw-r--r--cli/ops.rs24
1 files changed, 21 insertions, 3 deletions
diff --git a/cli/ops.rs b/cli/ops.rs
index d4add61e0..e4448c3b5 100644
--- a/cli/ops.rs
+++ b/cli/ops.rs
@@ -1793,9 +1793,27 @@ fn op_run(
c.env(entry.key().unwrap(), entry.value().unwrap());
});
- c.stdin(subprocess_stdio_map(inner.stdin()));
- c.stdout(subprocess_stdio_map(inner.stdout()));
- c.stderr(subprocess_stdio_map(inner.stderr()));
+ // TODO: make this work with other resources, eg. sockets
+ let stdin_rid = inner.stdin_rid();
+ if stdin_rid > 0 {
+ c.stdin(resources::get_file(stdin_rid)?);
+ } else {
+ c.stdin(subprocess_stdio_map(inner.stdin()));
+ }
+
+ let stdout_rid = inner.stdout_rid();
+ if stdout_rid > 0 {
+ c.stdout(resources::get_file(stdout_rid)?);
+ } else {
+ c.stdout(subprocess_stdio_map(inner.stdout()));
+ }
+
+ let stderr_rid = inner.stderr_rid();
+ if stderr_rid > 0 {
+ c.stderr(resources::get_file(stderr_rid)?);
+ } else {
+ c.stderr(subprocess_stdio_map(inner.stderr()));
+ }
// Spawn the command.
let child = c.spawn_async().map_err(DenoError::from)?;