diff --git a/docs/api.md b/docs/api.md index c8677a9240..93b6000c91 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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. diff --git a/docs/configuration.md b/docs/configuration.md index a731257ef3..70338bad01 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -100,3 +100,14 @@ $.log = (entry: LogEntry) => { } } ``` + +## $.timeout + +Specifies a timeout for the command execution. + +```js +$.timeout = '1s' +$.timeoutSignal= 'SIGKILL' + +await $`sleep 999` +``` diff --git a/docs/contribution.md b/docs/contribution.md index 0ba5ba683f..f903590190 100644 --- a/docs/contribution.md +++ b/docs/contribution.md @@ -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) \ No newline at end of file +The project is licensed under the [Apache-2.0](https://github.com/google/zx?tab=Apache-2.0-1-ov-file#readme) diff --git a/docs/process-promise.md b/docs/process-promise.md index a709c8eb7d..6f7c73adb4 100644 --- a/docs/process-promise.md +++ b/docs/process-promise.md @@ -58,7 +58,6 @@ await p.lines() // ['foo', 'bar'] await $`echo '{"foo": "bar"}'`.json() // {foo: 'bar'} ``` - ## `pipe()` Redirects the output of the process. @@ -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 @@ -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()) }, }) diff --git a/docs/setup.md b/docs/setup.md index b03be443a1..42d7256b15 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -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 @@ -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 @@ -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.