@0x-lerna-fork/run 中文文档教程
@0x-lerna-fork/run
在包含该脚本的每个包中运行 npm 脚本
安装 lerna 以访问 lerna
CLI .
Usage
$ lerna run <script> -- [..args] # runs npm run my-script in all packages that have it
$ lerna run test
$ lerna run build
# watch all packages and transpile on change, streaming prefixed output
$ lerna run --parallel watch
在包含该脚本的每个包中运行 npm 脚本。 双破折号 (--
) 是将破折号参数传递给脚本执行所必需的。
Options
lerna run
遵守 --concurrency
、--scope
和 --ignore
标志(参见 过滤标志)。
$ lerna run --scope my-component test
--npm-client <client>
必须是知道如何运行 npm 生命周期脚本的可执行文件。 默认的 --npm-client
是 npm
。
$ lerna run build --npm-client=yarn
也可以在 lerna.json
中配置:
{
"command": {
"run": {
"npmClient": "yarn"
}
}
}
--stream
立即从子进程流式输出,以原始进程为前缀 包裹名字。 这允许交错来自不同包的输出。
$ lerna run watch --stream
--parallel
类似于 --stream
,但完全无视并发性和拓扑排序,在所有匹配的包中立即运行给定的命令或脚本,并带有前缀流输出。 这是长时间运行的进程的首选标志,例如 npm run watch
run over many packages。
$ lerna run watch --parallel
注意:建议在使用时限制此命令的范围
--parallel
标志,因为可能会产生许多子进程 对你的 shell 的平静(或最大文件描述符限制, 例如)。 YMMV
--no-bail
# Run an npm script in all packages that contain it, ignoring non-zero (error) exit codes
$ lerna run --no-bail test
默认情况下,如果 任何 脚本运行返回非零退出代码,lerna run
将退出并出错。 传递 --no-bail
以禁用此行为,在包含它的所有 包中运行脚本,而不管退出代码如何。
--no-prefix
流输出时禁用包名称前缀(--stream
或 --parallel
)。 当将结果通过管道传输到其他进程(例如编辑器插件)时,此选项很有用。
@0x-lerna-fork/run
Run an npm script in each package that contains that script
Install lerna for access to the lerna
CLI.
Usage
$ lerna run <script> -- [..args] # runs npm run my-script in all packages that have it
$ lerna run test
$ lerna run build
# watch all packages and transpile on change, streaming prefixed output
$ lerna run --parallel watch
Run an npm script in each package that contains that script. A double-dash (--
) is necessary to pass dashed arguments to the script execution.
Options
lerna run
respects the --concurrency
, --scope
, and --ignore
flags (see Filter Flags).
$ lerna run --scope my-component test
--npm-client <client>
Must be an executable that knows how to run npm lifecycle scripts. The default --npm-client
is npm
.
$ lerna run build --npm-client=yarn
May also be configured in lerna.json
:
{
"command": {
"run": {
"npmClient": "yarn"
}
}
}
--stream
Stream output from child processes immediately, prefixed with the originating package name. This allows output from different packages to be interleaved.
$ lerna run watch --stream
--parallel
Similar to --stream
, but completely disregards concurrency and topological sorting, running a given command or script immediately in all matching packages with prefixed streaming output. This is the preferred flag for long-running processes such as npm run watch
run over many packages.
$ lerna run watch --parallel
Note: It is advised to constrain the scope of this command when using the
--parallel
flag, as spawning dozens of subprocesses may be harmful to your shell's equanimity (or maximum file descriptor limit, for example). YMMV
--no-bail
# Run an npm script in all packages that contain it, ignoring non-zero (error) exit codes
$ lerna run --no-bail test
By default, lerna run
will exit with an error if any script run returns a non-zero exit code. Pass --no-bail
to disable this behavior, running the script in all packages that contain it regardless of exit code.
--no-prefix
Disable package name prefixing when output is streaming (--stream
or --parallel
). This option can be useful when piping results to other processes, such as editor plugins.