You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/api.md
+71-29
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
# API Reference
2
2
3
-
## $.sync
3
+
## `$.sync`
4
4
Zx provides both synchronous and asynchronous command executions, returns [`ProcessOutput`](./process-output) or [`ProcessPromise`](./process-promise) respectively.
5
5
6
6
```js
7
7
constlist=await $`ls -la`
8
8
constdir=$.sync`pwd`
9
9
```
10
10
11
-
## $({...})
11
+
## `$({...})`
12
12
13
13
`$` object holds the default zx [configuration](./configuration), which is used for all execution. To specify a custom preset use `$` as factory:
@@ -59,7 +59,7 @@ const p = $({ signal })`sleep 9999`
59
59
setTimeout(() =>signal.abort('reason'), 1000)
60
60
```
61
61
62
-
### $({timeout})
62
+
### `$({timeout})`
63
63
64
64
The timeout option makes the process autokillable after the specified delay.
65
65
@@ -97,8 +97,9 @@ interface Options {
97
97
halt:boolean
98
98
}
99
99
```
100
+
See also [Configuration](./configuration).
100
101
101
-
## cd()
102
+
## `cd()`
102
103
103
104
Changes the current working directory.
104
105
@@ -116,7 +117,7 @@ cd(await $`mktemp -d`)
116
117
117
118
> ⚠️ `cd` invokes `process.chdir()` internally, so it does affect the global context. To keep `process.cwd()` in sync with separate `$` calls enable [syncProcessCwd()](#syncprocesscwd) hook.
118
119
119
-
## fetch()
120
+
## `fetch()`
120
121
121
122
A wrapper around the [node-fetch-native](https://www.npmjs.com/package/node-fetch-native)
122
123
package.
@@ -125,23 +126,23 @@ package.
125
126
constresp=awaitfetch('https://medv.io')
126
127
```
127
128
128
-
## question()
129
+
## `question()`
129
130
130
131
A wrapper around the [readline](https://nodejs.org/api/readline.html) package.
131
132
132
133
```js
133
134
constbear=awaitquestion('What kind of bear is best? ')
134
135
```
135
136
136
-
## sleep()
137
+
## `sleep()`
137
138
138
139
A wrapper around the `setTimeout` function.
139
140
140
141
```js
141
142
awaitsleep(1000)
142
143
```
143
144
144
-
## echo()
145
+
## `echo()`
145
146
146
147
A `console.log()` alternative which can take [ProcessOutput](#processoutput).
147
148
@@ -153,15 +154,15 @@ echo`Current branch is ${branch}.`
0 commit comments