运行每个 Lerna Package 中的 npm script
,如果有的话。
语法
$ lerna run <script>
Run an npm script in each package that contains that script
Positionals:
script The npm script to run. Pass flags to send to the npm client after -- [string] [required]
Command Options:
--npm-client Executable used to run scripts (npm, yarn, pnpm, ...). [string] [default: npm]
--stream Stream output with lines prefixed by package. [boolean]
--parallel Run script with unlimited concurrency, streaming prefixed output. [boolean]
--no-bail Continue running script despite non-zero exit in a given package. [boolean]
--no-prefix Do not prefix streaming output. [boolean]
--profile Profile script executions and output performance profile to default location. [boolean]
--profile-location Output performance profile to custom location instead of default project root. [string]
Filter Options:
--scope Include only packages with names matching the given glob. [string]
--ignore Exclude packages with names matching the given glob. [string]
--no-private Exclude packages with { "private": true } in their package.json. [boolean]
--since Only include packages that have been changed since the specified [ref].
If no ref is passed, it defaults to the most-recent tag. [string]
--exclude-dependents Exclude all transitive dependents when running a command
with --since, overriding the default "changed" algorithm. [boolean]
--include-dependents Include all transitive dependents when running a command
regardless of --scope, --ignore, or --since. [boolean]
--include-dependencies Include all transitive dependencies when running a command
regardless of --scope, --ignore, or --since. [boolean]
--include-merged-tags Include tags from merged branches when running a command with --since. [boolean]
Global Options:
--loglevel What level of logs to report. [string] [default: info]
--concurrency How many processes to use when lerna parallelizes tasks. [number] [default: 4]
--reject-cycles Fail if a cycle is detected among dependencies. [boolean]
--no-progress Disable progress bars. (Always off in CI) [boolean]
--no-sort Do not sort packages topologically (dependencies before dependents). [boolean]
--max-buffer Set max-buffer (in bytes) for subcommand execution [number]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Examples:
lerna run build -- --silent # `npm run build --silent` in all packages with a build script
选项
选项 | 描述 |
---|---|
--npm-client |
用于运行 script 的客户端(npm、yarn、pnpm),默认是 npm |
--stream |
流式输出,每一行的前缀是 Package 的名称 |
--parallel |
并行运行 + 流式输出 |
示例
并行运行每个 Lerna Package 中的 npm script(如果有的话)
$ lerna run dev --parallel
单独运行某个 Lerna Package 中的 npm script
$ lerna run dev --scope @wipi/client --stream