pnpm -r, --recursive
别名:m、multi、recursive、<command> -r
与以下命令一起使用时,在工作区的每个项目中运行命令:
installlistoutdatedpublishpackrebuildremoveunlinkupdatewhy
与以下命令一起使用时,会在工作区的每个项目中运行命令,但不包括根项目:
execruntestadd
如果你希望在运行脚本时也包含根项目,请将 [include-workspace-root] 设置设为 true。
用法示例:
pnpm -r publish
By default, recursive run, exec, and test execute projects in
topological order: dependencies run before their dependents. Use --no-sort
to disable graph ordering, or --parallel to start tasks without waiting for
dependencies.
Recursive list prints projects in the same order.
配置项#
To link workspace packages, set linkWorkspacePackages or pass --link-workspace-packages to the install.
--workspace-concurrency#
- Default: the smaller of 4 and the number of available CPU cores
- 类型:Number
设置同时运行的最大任务数。对于无限并发使用 Infinity。
在带 CPU 配额的容器中,例如 Kubernetes 的 CPU 限制,如果该配额小于容器可运行的 CPU 数量,则以该配额作为可用 CPU 核心数。小数配额会向下取整,且至少为 1。
A value of 0 or less means the number of available CPU cores minus its absolute value, and at least 1. The matching setting is workspaceConcurrency.
--[no-]bail#
- 默认值:true
- 类型:Boolean
如果为 true,则在任务抛出错误时停止。仍在运行的任务也会被停止。 On Unix they receive SIGTERM, and those still running two
seconds later receive SIGKILL. 在 Windows 上它们会立即结束,连同它们启动的每个进程一起。
--no-bail is accepted only by run, exec, test, start, stop, rebuild, install-test, and the pnpm <script> shorthand. 其他命令会拒绝它。
With --no-bail, tasks that depend on a failed task are skipped and independent tasks keep running.
该配置不影响退出码:只要有任务失败,命令就会以非零退出码结束。
See --no-bail.
示例(在每个包中运行测试,如果其中一个包中的测试失败仍继续):
pnpm -r --no-bail test
--[no-]sort#
- 默认值:true
- 类型:Boolean
When true, commands follow the workspace dependency graph. Recursive run
also applies relationships from the tasks setting. Pass --no-sort to
remove graph ordering. This also makes tasks, --reverse, and --resume-from
inapplicable.
示例:
pnpm -r --no-sort test
--reverse#
- 默认值: false
- 类型:Boolean
When true, dependency edges are reversed. For recursive run, this reverses
the resolved task graph, including relationships declared with dependsOn.
pnpm -r --reverse run clean
--parallel#
See pnpm run --parallel.
--resume-from <package_name>#
--stream#
See pnpm run --stream.
--aggregate-output#
See pnpm run --aggregate-output.
--report-summary#
See pnpm run --report-summary.
-w, --workspace-root#
See --workspace-root.
--filter <package_selector>#
--filter-prod <package_selector>#
See --filter-prod.