运行每个 Lerna Package 中的 npm script,如果有的话。

语法

  1. $ lerna run <script>
  2. Run an npm script in each package that contains that script
  3. Positionals:
  4. script The npm script to run. Pass flags to send to the npm client after -- [string] [required]
  5. Command Options:
  6. --npm-client Executable used to run scripts (npm, yarn, pnpm, ...). [string] [default: npm]
  7. --stream Stream output with lines prefixed by package. [boolean]
  8. --parallel Run script with unlimited concurrency, streaming prefixed output. [boolean]
  9. --no-bail Continue running script despite non-zero exit in a given package. [boolean]
  10. --no-prefix Do not prefix streaming output. [boolean]
  11. --profile Profile script executions and output performance profile to default location. [boolean]
  12. --profile-location Output performance profile to custom location instead of default project root. [string]
  13. Filter Options:
  14. --scope Include only packages with names matching the given glob. [string]
  15. --ignore Exclude packages with names matching the given glob. [string]
  16. --no-private Exclude packages with { "private": true } in their package.json. [boolean]
  17. --since Only include packages that have been changed since the specified [ref].
  18. If no ref is passed, it defaults to the most-recent tag. [string]
  19. --exclude-dependents Exclude all transitive dependents when running a command
  20. with --since, overriding the default "changed" algorithm. [boolean]
  21. --include-dependents Include all transitive dependents when running a command
  22. regardless of --scope, --ignore, or --since. [boolean]
  23. --include-dependencies Include all transitive dependencies when running a command
  24. regardless of --scope, --ignore, or --since. [boolean]
  25. --include-merged-tags Include tags from merged branches when running a command with --since. [boolean]
  26. Global Options:
  27. --loglevel What level of logs to report. [string] [default: info]
  28. --concurrency How many processes to use when lerna parallelizes tasks. [number] [default: 4]
  29. --reject-cycles Fail if a cycle is detected among dependencies. [boolean]
  30. --no-progress Disable progress bars. (Always off in CI) [boolean]
  31. --no-sort Do not sort packages topologically (dependencies before dependents). [boolean]
  32. --max-buffer Set max-buffer (in bytes) for subcommand execution [number]
  33. -h, --help Show help [boolean]
  34. -v, --version Show version number [boolean]
  35. Examples:
  36. 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(如果有的话)

    1. $ lerna run dev --parallel
  • 单独运行某个 Lerna Package 中的 npm script

    1. $ lerna run dev --scope @wipi/client --stream