Skip to content

Commit

Permalink
ReadableStream.from() not impl'd
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbhmr authored Nov 12, 2023
1 parent 964a312 commit 0d5a734
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/execa.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { spawn } from "node:child_process";
import { once } from "node:events";
import { Readable } from "node:stream";

export function $(strings, ...values) {
if (!Array.isArray(strings)) {
Expand All @@ -14,14 +15,14 @@ export function $(strings, ...values) {
argv = argv.map((arg) => arg.replace(keyRe, (m, i) => values[i]));
const argv0 = argv.shift();
const cp = spawn(argv0, argv, this);
const stdoutP = new Response(ReadableStream.from(cp.stdout)).text()
const stderrP = new Response(ReadableStream.from(cp.stderr)).text()
const stdoutP = new Response(Readable.toWeb(cp.stdout)).text();
const stderrP = new Response(Readable.toWeb(cp.stderr)).text();
cp.then = once(cp, "exit").then(async ([exitCode]) => {
const res = {
stdout: await stdoutP,
stderr: await stderrP,
exitCode: exitCode,
}
};
if ((this?.reject ?? true) && exitCode) {
throw res;
} else {
Expand Down

0 comments on commit 0d5a734

Please sign in to comment.