从 v7 迁移到 v8
v8.0.0 版本带来了许多特性、改进和修复,但也引入了一些破坏性更改。
$.verbose
默认设置为false
,但错误仍然会打印到stderr
。设置$.quiet = true
以禁止任何输出。
js
$.verbose = true // everything works like in v7
$.quiet = true // to completely turn off logging
ssh
API 已被删除。请安装 webpod 包。
js
// import {ssh} from 'zx' ↓
import {ssh} from 'webpod'
const remote = ssh('user@host')
await remote`echo foo`
- 默认情况下,zx 不再在 Windows 上查找
PowerShell
。 如果仍然需要它,请使用usePowerShell
助手启用
js
import { usePowerShell, useBash } from 'zx'
usePowerShell() // to enable powershell
useBash() // switch to bash, the default
要查找现代的 PowerShell v7+,请调用 usePwsh()
助手
js
import { usePwsh } from 'zx'
usePwsh()
- 现在默认禁用
$
调用之间的进程 cwd 同步。此功能通过异步钩子提供,现在可以直接控制。
js
import { syncProcessCwd } from 'zx'
syncProcessCwd() // restores legacy v7 behavior