summaryrefslogtreecommitdiff
path: root/js/process.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-03-28 21:09:46 +0100
committerRyan Dahl <ry@tinyclouds.org>2019-03-28 16:09:46 -0400
commitbdc455dd25b4c0d14fd30bc32c07206b2b93a007 (patch)
treef56468128eab8cdccbd010cccf2d37aaf1115a0c /js/process.ts
parentc25e262b04c15d4de7107cc131de467882e7dcec (diff)
Add Process.stderrOutput() (#1828)
Diffstat (limited to 'js/process.ts')
-rw-r--r--js/process.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/js/process.ts b/js/process.ts
index bf75b6b32..8ce83477a 100644
--- a/js/process.ts
+++ b/js/process.ts
@@ -83,7 +83,7 @@ export class Process {
}
/** Buffer the stdout and return it as Uint8Array after EOF.
- * You must have set stdout to "piped" in when creating the process.
+ * You must set stdout to "piped" when creating the process.
* This calls close() on stdout after its done.
*/
async output(): Promise<Uint8Array> {
@@ -97,6 +97,21 @@ export class Process {
}
}
+ /** Buffer the stderr and return it as Uint8Array after EOF.
+ * You must set stderr to "piped" when creating the process.
+ * This calls close() on stderr after its done.
+ */
+ async stderrOutput(): Promise<Uint8Array> {
+ if (!this.stderr) {
+ throw new Error("Process.stderrOutput: stderr is undefined");
+ }
+ try {
+ return await readAll(this.stderr);
+ } finally {
+ this.stderr.close();
+ }
+ }
+
close(): void {
close(this.rid);
}