Skip to content

Commit 4ea2897

Browse files
committed
fix exec & run subcommands stdin
1 parent e3219bf commit 4ea2897

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

sandbox.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,14 @@ export const sandboxExecCommand = new Command<SandboxContext>()
332332
const child = await sandbox.spawn("bash", {
333333
cwd: options.cwd,
334334
args: ["-c", command.join(" ")],
335+
stdin: "piped",
335336
stdout: options.quiet ? "null" : "inherit",
336337
stderr: options.quiet ? "null" : "inherit",
337338
});
338339

339-
const status = await child.status;
340+
const write = Deno.stdin.readable.pipeTo(child.stdin!);
341+
342+
const [status] = await Promise.all([child.status, write]);
340343
Deno.exit(status.code);
341344
});
342345

@@ -398,11 +401,14 @@ export const sandboxRunCommand = new Command<SandboxContext>()
398401
const child = await sandbox.spawn("bash", {
399402
cwd: options.cwd,
400403
args: ["-c", command.join(" ")],
404+
stdin: "piped",
401405
stdout: options.quiet ? "null" : "inherit",
402406
stderr: options.quiet ? "null" : "inherit",
403407
});
404408

405-
const status = await child.status;
409+
const write = Deno.stdin.readable.pipeTo(child.stdin!);
410+
411+
const [status] = await Promise.all([child.status, write]);
406412
Deno.exit(status.code);
407413
});
408414

0 commit comments

Comments
 (0)