diff --git a/docs/examples/subprocess.md b/docs/examples/subprocess.md index 3f1297cc00e631..e5956e1af52f5c 100644 --- a/docs/examples/subprocess.md +++ b/docs/examples/subprocess.md @@ -70,11 +70,13 @@ const p = Deno.run({ const { code } = await p.status(); +// Reading the outputs closes their pipes +const rawOutput = await p.output(); +const rawError = await p.stderrOutput(); + if (code === 0) { - const rawOutput = await p.output(); await Deno.stdout.write(rawOutput); } else { - const rawError = await p.stderrOutput(); const errorString = new TextDecoder().decode(rawError); console.log(errorString); }