pnpm exec
在项目范围内执行 shell 命令。
node_modules/.bin 被添加到 PATH,因此 pnpm exec 允许执行依赖项的命令。 The name of the current package is available through the environment variable PNPM_PACKAGE_NAME.
示例#
If you have Jest as a dependency of your project, there is no need to install Jest globally. Run it with pnpm exec:
pnpm exec jest
The exec part is actually optional when the command is not in conflict with a builtin pnpm command, so you may also run:
pnpm jest
配置项#
pnpm reads its own options up to the command name, before or after the exec keyword. Everything after the command name is passed to the executed command.
Both of these run jest in every project of the workspace:
pnpm -r exec jest
pnpm exec -r jest
This one runs jest in the current project only, with -r as an argument of jest:
pnpm exec jest -r
--recursive, -r#
在工作区的每个项目中执行 shell 命令。 The recursive options, such as --workspace-concurrency, --[no-]sort, and --reverse, apply.
示例#
为所有的软件包清理 node_modules 安装。
pnpm -r exec rm -rf node_modules
查看所有包的包信息。这应该与 --shell-mode(或 -c)选项一起使用,以使环境变量起作用。
pnpm -rc exec pnpm view \$PNPM_PACKAGE_NAME
--no-reporter-hide-prefix#
并行运行命令时不隐藏前缀。
--resume-from <package_name>#
Resume execution at a particular project. pnpm skips the projects a matching
record of the previous recursive exec says already passed. Without such a
record, it omits the named project's transitive dependencies, but still runs
the named project, its dependents, and unrelated projects in the selected
graph. See Workspace task
orchestration.
--parallel#
完全忽略并发和拓扑排序,在所有匹配的包中立即运行给定的脚本。对于许多包中长时间运行的进程,这是首选标志,例如漫长的构建进程。
--shell-mode, -c#
Runs the command inside a shell. Uses /bin/sh on UNIX and cmd.exe on Windows.