File tree 1 file changed +39
-1
lines changed 1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change 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
+ ```
You can’t perform that action at this time.
0 commit comments