Skip to content

从 v7 迁移到 v8

¥Migration from v7 to v8

v8.0.0 发布 带来了许多功能、改进和修复,但也引入了一些重大更改。

¥v8.0.0 release brought many features, improvements and fixes, but also has introduced a few breaking changes.

  1. $.verbose 默认设置为 false,但错误仍打印到 stderr。设置 $.quiet = true 以抑制任何输出。

    ¥$.verbose is set to false by default, but errors are still printed to stderr. Set $.quiet = true to suppress any output.

js
$.verbose = true // everything works like in v7

$.quiet = true   // to completely turn off logging
  1. ssh API 已被删除。安装 webpod 软件包。

    ¥ssh API was dropped. Install webpod package instead.

js
// import {ssh} from 'zx' ↓
import {ssh} from 'webpod'

const remote = ssh('user@host')
await remote`echo foo`
  1. 默认情况下,zx 在 Windows 上不再寻找 PowerShell。如果你仍然需要它,请使用 usePowerShell 辅助程序来启用:

    ¥zx is not looking for PowerShell anymore, on Windows by default. If you still need it, use the usePowerShell helper to enable:

js
import { usePowerShell, useBash } from 'zx'

usePowerShell() // to enable powershell
useBash()       // switch to bash, the default

要查找现代 PowerShell v7+,请改为调用 usePwsh() 辅助程序:

¥To look for modern PowerShell v7+, invoke usePwsh() helper instead:

js
import { usePwsh } from 'zx'

usePwsh()
  1. 现在默认情况下禁用 $ 调用之间的进程 cwd 同步。此功能是通过异步钩子提供的,现在可以直接控制。

    ¥Process cwd synchronization between $ invocations is now disabled by default. This functionality is provided via an async hook and can now be controlled directly.

js
import { syncProcessCwd } from 'zx'

syncProcessCwd() // restores legacy v7 behavior

google/zx 中文网 - 粤ICP备13048890号