From bd961c3bc305e90e760394d2f424c5360a67543b Mon Sep 17 00:00:00 2001 From: Makuza Mugabo Verite <53856673+makuzaverite@users.noreply.github.com> Date: Tue, 16 Mar 2021 13:05:04 +0200 Subject: [PATCH] fix(doc): update example for sub processes (#9798) --- docs/examples/subprocess.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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); }