Skip to content

Commit 49509e8

Browse files
committed
docs: add readme with usage
1 parent 315ee5c commit 49509e8

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,39 @@
1-
# bash
1+
# bash :boxing_glove:
2+
3+
Ergonomically run `bash` commands in Deno.
4+
5+
## Usage
6+
7+
Run any `bash` command:
8+
9+
```ts
10+
import { bash } from "https://deno.land/x/bash/mod.ts";
11+
12+
const result = await bash("echo 'hello world'");
13+
console.log(result); // hello world
14+
```
15+
16+
If the underlying command fails, `bash` will throw an error:
17+
18+
```ts
19+
import { bash, BashError } from "https://deno.land/x/bash/mod.ts";
20+
21+
try {
22+
const result = await bash("laskdjf");
23+
} catch (error) {
24+
if (error instanceof BashError) {
25+
console.error(error.message);
26+
}
27+
}
28+
```
29+
30+
By default, `bash` will strip the trailing newline from both the `stdout` output
31+
and `stderr` output. If you want to disable this behavior, pass
32+
`{ stripTrailingNewline: true }` as the second argument:
33+
34+
```ts
35+
import { bash } from "https://deno.land/x/bash/mod.ts";
36+
37+
const result = await bash("echo 'hello world'", { stripTrailingNewline: true });
38+
console.log(result); // hello world\n
39+
```

0 commit comments

Comments
 (0)