Releases: google/zx
8.1.5
8.1.4
We continue optimizing bundles and CI/CD pipelines.
- Update @webpod/ps to v0.0.0-beta.7 to sync internal zurk version. #855
- Split vendor chunk to reduce the
zx/core
entry size. #856 - Add bundle size check. #857
- Refactor the testing flow, remove duplicated tasks. #861
- Add missing types for the global
defaults
. #864 - Omit redundant YAML API extras. #866
Which gives us: 897 kB → 829 kB (-7.58%)
8.1.3
Nothing special today. We just keep improving the implementation.
Features
import {$} from 'zx'
zx/cli
exports its inners to allow more advanced usage.
Imagine, your own CLI tool that useszx
as a base:
#828
#!/usr/bin/env node
import './index.mjs'
import {main} from 'zx/cli'
main()
const getFixedSizeArray = (size) => {
const arr = []
return new Proxy(arr, {
get: (target, prop) =>
prop === 'push' && arr.length >= size
? () => {}
: target[prop],
})
}
const store = {
stdout: getFixedSizeArray(1),
stderr: getFixedSizeArray(1),
stdall: getFixedSizeArray(0),
}
const p = await $({ store })`echo foo`
p.stdout.trim() // 'foo'
p.toString() // ''
- Introduced sync methods for
ps
:
#840
import { ps } from 'zx'
const list1 = await ps()
const list2 = await tree()
// new methods
const list3 = ps.sync()
const list4 = tree.sync()
Chore
$.log
acceptskind: 'custom'
#834- Describe
$.verbose
and$.quiet
modes internals #835 - Mention
quotePowerShell
in docs #851 - Finally fixed the annoying flaky problem of the process end detection in Bun #839, coderef
- Suppress
async_hooks.createHook
warning on bun #848 - Remove node-abort-controller in favor of built-in node-fetch polyfill #842
- Add missing global types #853
8.1.2
Every new zx version is better than previous one. What have we here?
Features
const p = $`echo foo`
p.quiet() // enable silent mode
p.quiet(false) // then disable
p.verbose() // enable verbose/debug mode
p.verbose(false) // and turn it off
await p
- Aligned
ProcessPromise.isSmth()
API:
#823
const p = $`echo foo`
p.isHalted()
p.isVerbose()
p.isQuiet()
p.isNothrow()
Bug Fixes
- fix: apply EOL ensurer to the last chunk only #825
- fix(cli): return exit code 1 on incorrect inputs #826
- fix: set cjs bundle as legacy
main
entrypoint #827
Chore
- Published with npm provenance #818
- Minor polyfills optimizations #821
8.1.1
This release brings a pinch of sugar and minor fixes.
Features
- Introduced
$.preferLocal
option to prefernode_modules/.bin
located binaries over globally system installed ones.
#798
$.preferLocal = true
await $`c8 npm test`
await $({ preferLocal: true })`eslint .`
const p = $`echo 'foo\nbar'`
await p.text() // foo\n\bar\n
await p.text('hex') // 666f6f0a0861720a
await p.buffer() // Buffer.from('foo\n\bar\n')
await p.lines() // ['foo', 'bar']
await $`echo '{"foo": "bar"}'`.json() // {foo: 'bar'}
ProcessPromise
now exposes itssignal
reference.
#816
const p = $`sleep 999`
const {signal} = p
const res = fetch('https://example.com', {signal})
setTimeout(() => p.abort('reason'), 1000)
Fixes
8.1.0
This new release is a big deal. It brings significant improvements in reliability and compatibility.
- Switched to hybrid-scheme package: both ESM and CJS entry points are provided.
- Extended Node.js supported versions range: from 12.17.0 to the latest 22.x.x.
- Added compatibility with Deno 1.x.
- zx libdefs are now compatible with TS 4.0+.
New features
Added usePwsh()
helper to switch to PowerShell v7+ #790
import {usePwsh, useBash} from 'zx'
usePwsh()
$.shell // 'pwsh'
useBash()
$.shell // 'bash'
timeout
is now configurable $
opts #796
import {$} from 'zx'
await $({ timeout: 100 })`sleep 999`
$.timeout = 1000 // Sets default timeout for all commands
$.timeoutSignal = 'SIGKILL' // Sets signal to send on timeout
await $`sleep 999`
Added --cwd
option for CLI #804
zx --cwd=/some/path script.js
Introduced tmpdir
and tmpfile
helpers #803
import {tmpdir, tmpfile} from 'zx'
t1 = tmpdir() // /os/based/tmp/zx-1ra1iofojgg/
t2 = tmpdir('foo') // /os/based/tmp/zx-1ra1iofojgg/foo/
f1 = tmpfile() // /os/based/tmp/zx-1ra1iofojgg
f2 = tmpfile('f.txt') // /os/based/tmp/zx-1ra1iofojgg/foo.txt
f3 = tmpfile('f.txt', 'string or buffer')
8.0.2
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` // foo
You 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 compatibility
minimist
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.
-
$.verbose
is set tofalse
by default, but errors are still printed tostderr
. Set$.quiet = true
to suppress all output.
cafb90, #745, #569$.verbose = true // everything works like in v7 $.quiet = true // to completely turn off logging
-
ssh
API 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
powershell
anymore, on Windows by default. If you still need it, use theusePowerShell
helper:
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 DOM
fe0356 #735, #619, #722) - implemented
ProcessPromise.valueOf()
to simplify value comparisons 0640b8, #737, #690 - enhanced
--install
API: use depkeek for deps extraction 1a03a6 - removed
--experimental
toggle, 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
spinner
issue on weird TTY 1124e3, #755, #607 - migrated tests to native
node:test
cd1835