Skip to content

Commit

Permalink
chore: update docs for stderr changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Apr 6, 2024
1 parent 2d5a6ba commit 76d2fb6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions mod.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 76d2fb6

Please sign in to comment.