github google/zx 8.4.0
8.4.0 – Drip Detective

2 days ago

Try the new batch of enhancements: npm i zx@8.4.0 https://www.npmjs.com/package/zx/v/8.4.0

Changes

  • The CLI option --prefer-local now allows linking both external binaries and packages #1116 #1117
const cwd = tmpdir()
const external = tmpdir()
await fs.outputJson(path.join(external, 'node_modules/a/package.json'), {
  name: 'a',
  version: '1.0.0',
  type: 'module',
  exports: './index.js',
})
await fs.outputFile(
  path.join(external, 'node_modules/a/index.js'),
  `
export const a = 'AAA'
`
)
const script = `
import {a} from 'a'
console.log(a);
`
const out = await $`zx --cwd=${cwd} --prefer-local=${external} --test <<< ${script}`
assert.equal(out.stdout, 'AAA\n')
  • The quote has been slightly changed for a conner case, when zx literal gets an array.
    #999 #1113
const p = $({prefix: '', postfix: ''})`echo ${[1, '', '*', '2']}`

// before
p.cmd //  `echo 1  $'*' 2`) 

// after
p.cmd //  `echo 1 $'' $'*' 2`) 
  • Provided support for custom script extensions via CLI #1104 #1105
zx script.zx           # Unknown file extension "\.zx"
zx --ext=mjs script.zx # OK
  • Enhanced nothrow option to suppress any errors #1108 #1109
const err = new Error('BrokenSpawn')
const o = await $({
  nothrow: true,
  spawn() {
    throw err
  },
})`echo foo`
o.ok       // false
o.exitCode // null
o.message  // BrokenSpawn...
o.cause    // err
  • @types/node and @types/fs-extra deps replaced with triple-slash typing refs #1102
  • Made ProcessOutput iterable #1101
  • Handle inappropriate ProcessPromise instantiation #1097 #1098
  • Pass origin error as ProcessOuput cause #1110
  • Separated build and release steps #1106
  • Internal improvements
    • Introduced API bus #1083
    • Optimized ProcessOutput inners #1096 #1095
    • Pinned deps #1099 #1100
    • Switched to explicit .ts extensions for relative imports #1111

Don't miss a new zx release

NewReleases is sending notifications on new releases.