From e9041b9edc371f2cbd41a354591b5663f2bb4c84 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Sun, 24 Apr 2022 16:21:22 +0100 Subject: fix(runtime/js/spawn): Pass stdio options for spawn() and spawnSync() (#14358) --- runtime/js/40_spawn.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'runtime/js/40_spawn.js') diff --git a/runtime/js/40_spawn.js b/runtime/js/40_spawn.js index c55ce657d..3b609be8b 100644 --- a/runtime/js/40_spawn.js +++ b/runtime/js/40_spawn.js @@ -166,13 +166,13 @@ } } - function spawn(command, options) { // TODO(@crowlKats): more options (like input)? - return spawnChild(command, { - ...options, - stdin: "null", - stdout: "piped", - stderr: "piped", - }).output(); + function spawn(command, options) { + if (options?.stdin === "piped") { + throw new TypeError( + "Piped stdin is not supported for this function, use 'Deno.spawnChild()' instead", + ); + } + return spawnChild(command, options).output(); } function spawnSync(command, { @@ -182,7 +182,15 @@ env = {}, uid = undefined, gid = undefined, - } = {}) { // TODO(@crowlKats): more options (like input)? + stdin = "null", + stdout = "piped", + stderr = "piped", + } = {}) { + if (stdin === "piped") { + throw new TypeError( + "Piped stdin is not supported for this function, use 'Deno.spawnChild()' instead", + ); + } return core.opSync("op_spawn_sync", { cmd: pathFromURL(command), args: ArrayPrototypeMap(args, String), @@ -191,9 +199,9 @@ env: ObjectEntries(env), uid, gid, - stdin: "null", - stdout: "piped", - stderr: "piped", + stdin, + stdout, + stderr, }); } -- cgit v1.2.3