Releases: google/zx
8.0.1
8.0.0
We are thrilled to announce the release of zx v8.0.0! 🎉
With this release, we have introduced a lot of new features, improvements, and bug fixes.
We have also made some breaking changes, so please read the following release notes carefully.
🚀 New Shiny Features
Squashed deps: we use esbuild with custom plugins to forge js bundles and dts-bundle-generator for typings
2acb0f, #722
More safety, more stability and significantly reduced installation time. Zx now is ~20x smaller.
npx [email protected]
npm install [email protected]Options presets are here. To implement this, we have also completely refactored the zx core, and now it's available as a separate package – zurk
aeec7a, #733, #600
const $$ = $({quiet: true})
await $$`echo foo`
$({nothrow: true})`exit 1`We have introduced $.sync() API
1f8c8b, #738, #681, 1d8aa9, #739
import {$} from 'zx'
const { output } = $.sync`echo foo` // fooYou can also override the internal API to implement pools, test mocking, etc.
$.spawnSync = () => {} // defaults to `child_process.spawnSync`The input option is now available to pass data to the command.
b38972, #736
const p1 = $({ input: 'foo' })`cat`
const p2 = $({ input: Readable.from('bar') })`cat`
const p3 = $({ input: Buffer.from('baz') })`cat`
const p4 = $({ input: p3 })`cat`
const p5 = $({ input: await p3 })`cat`AbortController has been introduced to abort the command execution. It's available via the ac option.
fa4a7b, #734, #527
const ac = new AbortController()
const p = $({ ac })`sleep 9999`
setTimeout(() => ac.abort(), 100)If not specified, the default instance will be used. Abortion trigger is also available via PromiseResponse:
const p = $`sleep 9999`
setTimeout(() => p.abort(), 100)kill method is exposed now. To terminate any (not only zx starter) process:
import { kill } from 'zx'
await kill(123)
await kill(123, 'SIGKILL')Btw, we have replaced ps-tree with @webpod/ps & @webpod/ingrid, and exposed ps util:
import {ps} from 'zx'
const children = await ps.tree(123)
/**
[
{pid: 124, ppid: 123},
{pid: 125, ppid: 123}
]
*/
const children2 = await ps.tree({pid: 123, recursive: true})
/**
[
{pid: 124, ppid: 123},
{pid: 125, ppid: 123},
{pid: 126, ppid: 124},
{pid: 127, ppid: 124},
{pid: 128, ppid: 124},
{pid: 129, ppid: 125},
{pid: 130, ppid: 125},
]
*/Introduced $.postfix option. It's like a $.prefix, but for the end of the command.
fb9554, #756, #536
import {$} from 'zx'
$.postfix = '; exit $LastExitCode' // for PowerShell compatibilityminimist API exposed
#661
import { minimist } from 'zx'
const argv = minimist(process.argv.slice(2), {})Fixed npm package name pattern on --install mode
956dcc, #659, #660, #663
import '@qux/pkg' // valid
import '@qux/pkg/entry' // was invalid before and valid now⚠️ Breaking changes
We've tried our best to avoid them, but it was necessary.
-
$.verboseis set tofalseby default, but errors are still printed tostderr. Set$.quiet = trueto suppress all output.
cafb90, #745, #569$.verbose = true // everything works like in v7 $.quiet = true // to completely turn off logging
-
sshAPI was dropped. Install webpod package instead.
8925a1, #750// import {ssh} from 'zx' ↓ import {ssh} from 'webpod' const remote = ssh('user@host') await remote`echo foo`
-
zx is not looking for
powershellanymore, on Windows by default. If you still need it, use theusePowerShellhelper:
24dcf3, #757import { usePowerShell, useBash } from 'zx' usePowerShell() // to enable powershell useBash() // switch to bash, the default
-
Process cwd synchronization between
$invocations is disabled by default. This functionality is provided via an async hook and can now be controlled directly.
d79a63, #765import { syncProcessCwd } from 'zx' syncProcessCwd() // restores legacy v7 behavior
🧰 Other Improvements
- added dev (snapshot publish) releases 0c97b9 #723
- tsconfig: dropped
lib DOMfe0356 #735, #619, #722) - implemented
ProcessPromise.valueOf()to simplify value comparisons 0640b8, #737, #690 - enhanced
--installAPI: use depkeek for deps extraction 1a03a6 - removed
--experimentaltoggle, all APIs are available by default 8a7a8f, #751 - added minute support in duration b02fd5, #703, #704
- enhanced stack extraction to support bun 2026d4, #752
- fixed
spinnerissue on weird TTY 1124e3, #755, #607 - migrated tests to native
node:testcd1835
7.2.3
7.2.2
7.2.1
7.2.0
🐚 zx v7.2.0 release! 🎉
A tool for writing better scripts
In this release:
- Helpers retry() & spinner() now available in zx without the experimental flag.
- Added support for
~~~blocks in markdown scripts. - Updated npm dependencies.
- Added support for ssh commands via webpod.
PS: Plan for the next v8 release.
7.1.1
7.1.0
Autoinstall
This release introduces a new flag --install which will parse and install all required or imported packages automatically.
import sh from 'tinysh'
sh.say('Hello, world!')And running zx --install script.mjs will trigger installation of tinysh package! It even possible to specify a needed version in comment with @ symbol:
import sh from 'tinysh' // @^1.0.0PowerShell
Another big change is for Windows. Now, the default shell on Windows is powershell.exe.
This should fix a lot of issues with "dollar" signs.
Fixes
- Minimist now correctly parses argv when using zx cli.
7.0.8
What's Changed
- fix: avoid redundant
$.verbosereassignment on CLI init by @antongolub in #475 - fix: let $.spawn be configurable by @antongolub in #486
Full Changelog: 7.0.7...7.0.8
