Skip to content

Releases: google/zx

8.2.1

08 Nov 13:41
880c4f4
Compare
Choose a tag to compare
  • #936 fixes endless streams piping
  • #930 enables custom extensions support

8.2.0

31 Oct 20:01
6eb540f
Compare
Choose a tag to compare

Pipes supercharge today! πŸš€

Features

  • Delayed piping. You can fill dependent streams at any time during the origin process lifecycle (even when finished) without losing data. #914
const result = $`echo 1; sleep 1; echo 2; sleep 1; echo 3`
const piped1 = result.pipe`cat`
let piped2

setTimeout(() => {
  piped2 = result.pipe`cat`
}, 1500)

await piped1
assert.equal((await piped1).toString(), '1\n2\n3\n')
assert.equal((await piped2).toString(), '1\n2\n3\n')
const file = tempfile()
const fileStream = fs.createWriteStream(file)
const p = $`echo "hello"`
  .pipe(
    new Transform({
      transform(chunk, encoding, callback) {
        callback(null, String(chunk).toUpperCase())
      },
    })
  )
  .pipe(fileStream)

p instanceof WriteStream             // true
await p === fileStream               // true
(await fs.readFile(file)).toString() // 'HELLO\n'

Chore

8.1.9

06 Oct 19:34
c3061ab
Compare
Choose a tag to compare

Today's release is a minor update that includes:

Enhancements

  • We have replaced ProcessOutput fields with lazy getters to reduce mem consumption #903, #908
  • Reduced ReDos risks for codeblock patterns #906
  • Kept argv reference on update #916
  • Strengthened Shell interface to properly handle sync mode #915:
expectType<ProcessPromise>($`cmd`)
expectType<ProcessPromise>($({ sync: false })`cmd`)
expectType<ProcessOutput>($({ sync: true })`cmd`)
expectType<ProcessOutput>($.sync`cmd`)

Fixes

  • Corrected stdall fill for $.sync calls: #911, #912

8.1.8

19 Sep 15:18
9354a39
Compare
Choose a tag to compare
  • Apply the proper TeplateStringArray detection #904, #905
  • PromiseProcess got lazy getters to optimize mem usage #903

8.1.7

17 Sep 12:36
5038ec5
Compare
Choose a tag to compare

Step by step on the road to improvements

Fixes

Finally, we've fixed the issue with piped process rejection #640 #899:

const p1 = $`exit 1`.pipe($`echo hello`)
try {
  await p1
} catch (e) {
  assert.equal(e.exitCode, 1)
}

const p2 = await $({ nothrow: true })`echo hello && exit 1`.pipe($`cat`)
assert.equal(p2.exitCode, 0)
assert.equal(p2.stdout.trim(), 'hello')

Enhancements

Added cmd display to ProcessPromise #891:

const foo = 'bar'
const p = $`echo ${foo}`

p.cmd // 'echo bar'

and duration field to ProcessOutput #892:

const p = $`sleep 1`.nothrow()
const o = await p

o.duration // ~1000 (in ms)

Enabled zurk-like pipe string literals #900:

const p = await $`echo foo`.pipe`cat`
p.stdout.trim() // 'foo'

8.1.6

11 Sep 13:00
ac2567f
Compare
Choose a tag to compare

Improvements & Fixes

  • The $.preferLocal option now also accepts a directory #886, #887.
$.preferLocal = true             // injects node_modules/.bin to the $PATH
$.preferLocal = '/foo/bar'       // attaches /foo/bar to the $PATH
$.preferLocal = ['/bar', '/baz'] // now the $PATH includes both /bar and /baz

Why not just $.env['PATH'] = 'extra:' + '$.env['PATH']?
Well, the API internally does the same, but also handles the win paths peculiarities.

  • Provided $.killSignal option for the symmetry with the $.timeoutSignal. You can override the default termination flow #885:
$.killSignal = 'SIGKILL'

const p = $({nothrow: true})`sleep 10000`
setTimeout(p.kill, 100)
  
(await p).signal // SIGKILL
  • $ opt presets became chainable #883:
const $$ = $({ nothrow: true })
assert.equal((await $$`exit 1`).exitCode, 1)

const $$$ = $$({ sync: true }) // Both {nothrow: true, sync: true} are applied
assert.equal($$$`exit 2`.exitCode, 2)
  • Enhanced the internal Duration parser #884:
const p = $({timeout: '1mss'})`sleep 999` // raises an error now
  • Abortion signal listeners are now removed after the process completes #881, #889, zurk#12, zurk#13.
  • Extended integration tests matrix, added nodejs-nightly builds and TS dev snapshots #888

8.1.5

28 Aug 21:08
8c3730e
Compare
Choose a tag to compare

We've rolled out a new release!

Fixes

  • Added the minimist typings to the dts bundle. #872 brings the fix.
  • Re-enabled the YAML extra
    API. #870 #879

Chores

  • Clarified cd(), within() and syncProcessCwd() interactions. #878
  • Included mention of the cwd option in the documentation. #868
  • Test enhancements. #877 #880

8.1.4

04 Jul 10:44
d7d074d
Compare
Choose a tag to compare

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

19 Jun 20:53
a3b7316
Compare
Choose a tag to compare

Nothing special today. We just keep improving the implementation.

Features

  • ESM support is now available for Node.js v12 (previously was cjs only):

    #824, #827, #828
import {$} from 'zx'
  • zx/cli exports its inners to allow more advanced usage.
    Imagine, your own CLI tool that uses zx as a base:

    #828
#!/usr/bin/env node

import './index.mjs'
import {main} from 'zx/cli'

main()
  • Provide intermediate store configuration for fine-grained control of memory usage.

    #650, #849
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 accepts kind: '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

27 May 16:30
73f0558
Compare
Choose a tag to compare

Every new zx version is better than previous one. What have we here?

Features

  • Added ProcessPromise.verbose() to enhance debugging experience.

    #820, #710
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