From 9898e0a731e645a01f2f6d0b9af9f943095ad777 Mon Sep 17 00:00:00 2001 From: Yoav Balasiano Date: Mon, 8 Apr 2024 16:48:21 +0300 Subject: [PATCH] Improve bun shell docs examples (#10052) --- docs/runtime/shell.md | 5 ++++- test/js/bun/shell/bunshell-file.test.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/runtime/shell.md b/docs/runtime/shell.md index 73b70fb66f3a1a..0d13c56a11250d 100644 --- a/docs/runtime/shell.md +++ b/docs/runtime/shell.md @@ -99,6 +99,7 @@ console.log(stderr); The default handling of non-zero exit codes can be configured by calling `.nothrow()` or `.throws(boolean)` on the `$` function itself. ```js +import { $ } from "bun"; // shell promises will not throw, meaning you will have to // check for `exitCode` manually on every shell command. $.nothrow(); // equivilent to $.throws(false) @@ -108,6 +109,8 @@ $.throws(true); // alias for $.nothrow() $.throws(false); + +await $`something-that-may-fail`; // No exception thrown ``` ## Redirection @@ -149,7 +152,7 @@ The following JavaScript objects are supported for redirection to: To redirect the output from JavaScript objects to stdin, use the `<` operator: ```js -import { $, file } from "bun"; +import { $ } from "bun"; const response = new Response("hello i am a response body"); diff --git a/test/js/bun/shell/bunshell-file.test.ts b/test/js/bun/shell/bunshell-file.test.ts index fc340c93d99564..294259298b77dc 100644 --- a/test/js/bun/shell/bunshell-file.test.ts +++ b/test/js/bun/shell/bunshell-file.test.ts @@ -1,4 +1,4 @@ -import { $, file } from "bun"; +import { $ } from "bun"; import { test, expect } from "bun:test"; test("$ with Bun.file prints the path", async () => {