Skip to content

Commit

Permalink
docs: add missing parts (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub authored Dec 23, 2024
1 parent 260aa0a commit 504a960
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ await spinner(() => $`long-running command`)
await spinner('working...', () => $`sleep 99`)
```

And it's disabled for `CI` by default.

## glob()

The [globby](https://github.com/sindresorhus/globby) package.
Expand Down
11 changes: 11 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,14 @@ $.log = (entry: LogEntry) => {
}
}
```

## $.timeout

Specifies a timeout for the command execution.

```js
$.timeout = '1s'
$.timeoutSignal= 'SIGKILL'

await $`sleep 999`
```
2 changes: 1 addition & 1 deletion docs/contribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ All submissions, including submissions by project members, require review. We us

## License

The project is licensed under the [Apache-2.0](https://github.com/google/zx?tab=Apache-2.0-1-ov-file#readme)
The project is licensed under the [Apache-2.0](https://github.com/google/zx?tab=Apache-2.0-1-ov-file#readme)
12 changes: 10 additions & 2 deletions docs/process-promise.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ await p.lines() // ['foo', 'bar']
await $`echo '{"foo": "bar"}'`.json() // {foo: 'bar'}
```


## `pipe()`

Redirects the output of the process.
Expand Down Expand Up @@ -87,6 +86,15 @@ const p = $`echo "hello"`
const o = await p
```

And the `ProcessPromise` itself is compatible with the standard `Stream.pipe` API:

```js
const { stdout } = await fs
.createReadStream(await fs.writeFile(file, 'test'))
.pipe(getUpperCaseTransform())
.pipe($`cat`)
```

Pipes can be used to show a real-time output of the process:

```js
Expand Down Expand Up @@ -161,7 +169,7 @@ In short, combine anything you want:
```js
const getUpperCaseTransform = () => new Transform({
transform(chunk, encoding, callback) {
callback(null, String(chunk).toUpperCase())
callback(null, String(chunk).toUpperCase())
},
})

Expand Down
11 changes: 8 additions & 3 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* JavaScript Runtime:
* Node.js 12.17.0 or later
* Bun 1.0.0 or later
* Deno 1.x
* Deno 1.x, 2.x
* Some kind of bash or PowerShell

## Install
Expand Down Expand Up @@ -74,8 +74,8 @@ const opts: Options = {
We use [esbuild](https://dev.to/antongolub/how-and-why-do-we-bundle-zx-1ca6) to produce a static build that allows us to solve several issues at once:
* Reduce the pkg size and install time.
* Make npx (yarn dlx / bunx) invocations reproducible.
* Provide support for wide range of Node.js versions: from 12 to 22.
* Make auditing easier: complete code in one place.
* Provide support for wide range of Node.js versions: from 12 to 23.
* Make auditing easier: complete code is in one place.

### Composite

Expand All @@ -85,3 +85,8 @@ zx exports several entry points adapted for different use cases:
* `zx/cli` – to run zx scripts from the command line.
* `zx/core` – to use zx template spawner as part of 3rd party libraries with alternating set of utilities.

### Typed
The library is written in TypeScript 5 and provides comprehensive type definitions for TS users.
* Libdefs are bundled via [dts-bundle-generator](https://github.com/timocov/dts-bundle-generator).
* Compatible with TS 4.0 and later.
* Requires `@types/node` and `@types/fs-extra` to be installed.

0 comments on commit 504a960

Please sign in to comment.