From 1ea8a2984a2cfef7d84523f59887455d20afe897 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 6 Apr 2024 10:53:54 -0400 Subject: [PATCH] chore: update docs for stderr changes (#258) --- README.md | 13 ++++++++++--- mod.test.ts | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8a210bb..63f7bbe 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,13 @@ const result = await $`echo 1 && echo 2`.lines(); console.log(result); // ["1", "2"] ``` +Get stderr's text: + +```ts +const result = await $`deno eval "console.error(1)"`.text("stderr"); +console.log(result); // 1 +``` + Working with a lower level result that provides more details: ```ts @@ -89,10 +96,10 @@ console.log(output.stdoutJson); Getting the combined output: ```ts -const result = await $`deno eval 'console.log(1); console.error(2); console.log(3);'` - .captureCombined(); +const text = await $`deno eval 'console.log(1); console.error(2); console.log(3);'` + .text("combined"); -console.log(result.combined); // 1\n2\n3\n +console.log(text); // 1\n2\n3\n ``` ### Piping diff --git a/mod.test.ts b/mod.test.ts index 215bec8..0725cd4 100644 --- a/mod.test.ts +++ b/mod.test.ts @@ -280,6 +280,11 @@ Deno.test("stderrJson", async () => { assertEquals(output.stderrJson === output.stderrJson, true); // should be memoized }); +Deno.test("stderr text", async () => { + const result = await $`deno eval "console.error(1)"`.text("stderr"); + assertEquals(result, "1"); +}); + Deno.test("should handle interpolation", async () => { const output = await $`deno eval 'console.log(${5});'`.stdout("piped"); assertEquals(output.code, 0);