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-29Lines changed: 71 additions & 29 deletions
Display the source diff
Display the rich diff
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)
The [@webpod/ps](https://github.com/webpod/ps) package to provide a cross-platform way to list processes.
The [os](https://nodejs.org/api/os.html) package.
352
353
353
354
```js
354
355
await $`cd ${os.homedir()} && mkdir example`
355
356
```
356
357
357
-
## path
358
+
## `path`
358
359
359
360
The [path](https://nodejs.org/api/path.html) package.
360
361
361
362
```js
362
363
await $`mkdir ${path.join(basedir, 'output')}`
363
364
```
364
365
365
-
## yaml
366
+
## `yaml`
366
367
367
368
The [yaml](https://www.npmjs.com/package/yaml) package.
368
369
369
370
```js
370
371
console.log(YAML.parse('foo: bar').foo)
371
372
```
372
373
373
-
## dotenv
374
+
## `dotenv`
375
+
374
376
The [envapi](https://www.npmjs.com/package/envapi) package.
375
377
An API to interact with environment vars in [dotenv](https://www.npmjs.com/package/dotenv) format.
0 commit comments