summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/40_spawn.js52
1 files changed, 42 insertions, 10 deletions
diff --git a/runtime/js/40_spawn.js b/runtime/js/40_spawn.js
index 7a2f06b6a..54914dc09 100644
--- a/runtime/js/40_spawn.js
+++ b/runtime/js/40_spawn.js
@@ -77,21 +77,27 @@
return this.#pid;
}
- #stdinRid;
#stdin = null;
get stdin() {
+ if (this.#stdin == null) {
+ throw new TypeError("stdin is not piped");
+ }
return this.#stdin;
}
- #stdoutRid;
#stdout = null;
get stdout() {
+ if (this.#stdout == null) {
+ throw new TypeError("stdout is not piped");
+ }
return this.#stdout;
}
- #stderrRid;
#stderr = null;
get stderr() {
+ if (this.#stderr == null) {
+ throw new TypeError("stderr is not piped");
+ }
return this.#stderr;
}
@@ -111,17 +117,14 @@
this.#pid = pid;
if (stdinRid !== null) {
- this.#stdinRid = stdinRid;
this.#stdin = writableStreamForRid(stdinRid);
}
if (stdoutRid !== null) {
- this.#stdoutRid = stdoutRid;
this.#stdout = readableStreamForRid(stdoutRid);
}
if (stderrRid !== null) {
- this.#stderrRid = stderrRid;
this.#stderr = readableStreamForRid(stderrRid);
}
@@ -159,9 +162,21 @@
]);
return {
- status,
- stdout,
- stderr,
+ success: status.success,
+ code: status.code,
+ signal: status.signal,
+ get stdout() {
+ if (stdout == null) {
+ throw new TypeError("stdout is not piped");
+ }
+ return stdout;
+ },
+ get stderr() {
+ if (stderr == null) {
+ throw new TypeError("stderr is not piped");
+ }
+ return stderr;
+ },
};
}
@@ -198,7 +213,7 @@
"Piped stdin is not supported for this function, use 'Deno.spawnChild()' instead",
);
}
- return core.opSync("op_spawn_sync", {
+ const result = core.opSync("op_spawn_sync", {
cmd: pathFromURL(command),
args: ArrayPrototypeMap(args, String),
cwd: pathFromURL(cwd),
@@ -210,6 +225,23 @@
stdout,
stderr,
});
+ return {
+ success: result.status.success,
+ code: result.status.code,
+ signal: result.status.signal,
+ get stdout() {
+ if (result.stdout == null) {
+ throw new TypeError("stdout is not piped");
+ }
+ return result.stdout;
+ },
+ get stderr() {
+ if (result.stderr == null) {
+ throw new TypeError("stderr is not piped");
+ }
+ return result.stderr;
+ },
+ };
}
window.__bootstrap.spawn = {