Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@spryker-lerna/exec

lerna22MIT5.1.4

Execute an arbitrary command in each package

lerna, command

readme

@lerna/exec

Execute an arbitrary command in each package

Install lerna for access to the lerna CLI.

Usage

$ lerna exec -- <command> [..args] # runs the command in all packages
$ lerna exec -- rm -rf ./node_modules
$ lerna exec -- protractor conf.js

Run an arbitrary command in each package. A double-dash (--) is necessary to pass dashed flags to the spawned command, but is not necessary when all the arguments are positional.

The name of the current package is available through the environment variable LERNA_PACKAGE_NAME:

$ lerna exec -- npm view \$LERNA_PACKAGE_NAME

You may also run a script located in the root dir, in a complicated dir structure through the environment variable LERNA_ROOT_PATH:

$ lerna exec -- node \$LERNA_ROOT_PATH/scripts/some-script.js

Options

lerna exec accepts all filter flags.

$ lerna exec --scope my-component -- ls -la

The commands are spawned in parallel, using the concurrency given (except with --parallel). The output is piped through, so not deterministic. If you want to run the command in one package after another, use it like this:

$ lerna exec --concurrency 1 -- ls -la

--stream

Stream output from child processes immediately, prefixed with the originating package name. This allows output from different packages to be interleaved.

$ lerna exec --stream -- babel src -d lib

--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 babel src -d lib -w run over many packages.

$ lerna exec --parallel -- babel src -d lib -w

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 a command, ignoring non-zero (error) exit codes
$ lerna exec --no-bail <command>

By default, lerna exec will exit with an error if any execution returns a non-zero exit code. Pass --no-bail to disable this behavior, executing in all packages 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.

--profile

Profiles the command executions and produces a performance profile which can be analyzed using DevTools in a Chromium-based browser (direct url: devtools://devtools/bundled/devtools_app.html). The profile shows a timeline of the command executions where each execution is assigned to an open slot. The number of slots is determined by the --concurrency option and the number of open slots is determined by --concurrency minus the number of ongoing operations. The end result is a visualization of the parallel execution of your commands.

The default location of the performance profile output is at the root of your project.

$ lerna exec --profile -- <command>

Note: Lerna will only profile when topological sorting is enabled (i.e. without --parallel and --no-sort).

--profile-location <location>

You can provide a custom location for the performance profile output. The path provided will be resolved relative to the current working directory.

$ lerna exec --profile --profile-location=logs/profile/ -- <command>

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

5.1.4 (2022-06-04)

Note: Version bump only for package @spryker-lerna/exec

5.1.0 (2022-06-03)

Bug Fixes

  • scope: update packages scopes (eb0de43)

5.0.0 (2022-05-24)

Note: Version bump only for package @lerna/exec

4.0.0 (2021-02-10)

Features

  • Consume named exports of sibling modules (63499e3)
  • deps: execa@^4.1.0 (9051dca)
  • deps: p-map@^4.0.0 (92b1364)
  • Drop support for Node v6.x & v8.x (ff4bb4d)

BREAKING CHANGES

  • Node v6.x & v8.x are no longer supported. Please upgrade to the latest LTS release.

Here's the gnarly one-liner I used to make these changes:

npx lerna exec --concurrency 1 --stream -- 'json -I -f package.json -e '"'"'this.engines=this.engines||{};this.engines.node=">= 10.18.0"'"'"

(requires npm i -g json beforehand)

3.21.0 (2020-05-13)

Note: Version bump only for package @lerna/exec

3.20.0 (2019-12-27)

Bug Fixes

  • collect-dependents: Avoid skipping dependents of cyclic dependencies (#2380) (bd19a34)

Features

  • Add --profile option to lerna exec and lerna run (#2376) (6290174)

3.18.5 (2019-11-20)

Note: Version bump only for package @lerna/exec

3.18.4 (2019-11-08)

Bug Fixes

  • filter-options: Ensure --include-merged-tags is available to all --since-filterable commands (287bcd8), closes #2332

3.18.0 (2019-10-15)

Features

3.16.5 (2019-10-07)

Note: Version bump only for package @lerna/exec

3.16.0 (2019-07-18)

Bug Fixes

  • package-graph: Flatten cycles to avoid skipping packages (#2185) (b335763)

Features

3.15.0 (2019-06-09)

Note: Version bump only for package @lerna/exec

3.14.2 (2019-06-09)

Note: Version bump only for package @lerna/exec

3.14.0 (2019-05-14)

Features

  • exec: Add just-in-time queue management (23736e5)

3.13.3 (2019-04-17)

Bug Fixes

  • child-process: Centralize exitCode translation from string codes into numbers (09c0103), closes #2031
  • exec: Handle node string error codes before setting process.exitCode (#2031) (c599c64)

3.13.1 (2019-02-26)

Note: Version bump only for package @lerna/exec

3.13.0 (2019-02-15)

Features

  • meta: Add repository.directory field to package.json (aec5023)
  • meta: Normalize package.json homepage field (abeb4dc)

3.12.1 (2019-02-14)

Note: Version bump only for package @lerna/exec

3.12.0 (2019-02-14)

Note: Version bump only for package @lerna/exec

3.11.0 (2019-02-08)

Note: Version bump only for package @lerna/exec

3.10.6 (2019-01-19)

Bug Fixes

  • exec: Tweak description (68a0685)
  • options: Document negated boolean options explicitly (8bc9669)

3.10.1 (2019-01-09)

Note: Version bump only for package @lerna/exec

3.10.0 (2019-01-08)

Note: Version bump only for package @lerna/exec

3.9.0 (2019-01-08)

Note: Version bump only for package @lerna/exec

3.8.5 (2019-01-05)

Note: Version bump only for package @lerna/exec

3.8.1 (2018-12-31)

Note: Version bump only for package @lerna/exec

3.7.2 (2018-12-21)

Note: Version bump only for package @lerna/exec

3.7.1 (2018-12-20)

Note: Version bump only for package @lerna/exec

3.7.0 (2018-12-19)

Note: Version bump only for package @lerna/exec

3.6.0 (2018-12-07)

Note: Version bump only for package @lerna/exec

3.5.0 (2018-11-27)

Note: Version bump only for package @lerna/exec

3.3.2 (2018-09-12)

Note: Version bump only for package @lerna/exec

3.3.0 (2018-09-06)

Bug Fixes

3.1.3 (2018-08-21)

Note: Version bump only for package @lerna/exec

3.1.2 (2018-08-20)

Bug Fixes

  • Setup instance.filteredPackages explicitly (32357f8)

3.1.0 (2018-08-17)

Note: Version bump only for package @lerna/exec

3.0.6 (2018-08-16)

Note: Version bump only for package @lerna/exec

3.0.5 (2018-08-15)

Note: Version bump only for package @lerna/exec

3.0.2 (2018-08-11)

Bug Fixes

  • exec: Allow config files to override defaults (2335149)

3.0.0 (2018-08-10)

Note: Version bump only for package @lerna/exec

3.0.0-rc.0 (2018-07-27)

Features

  • Add description from --help summary [skip ci] (9b65d8e)
  • cli: Upgrade to Yargs 12 (7899ab8)
  • command: Remove .defaultOptions() from option resolution stack (2b27a54)
  • Count packages affected in command summary logging (5f5e585)

3.0.0-beta.21 (2018-05-12)

Bug Fixes

  • child-process: Prevent duplicate logs when any package-oriented execution fails (d3a8128)

3.0.0-beta.20 (2018-05-07)

Note: Version bump only for package @lerna/exec

3.0.0-beta.19 (2018-05-03)

Note: Version bump only for package @lerna/exec

3.0.0-beta.18 (2018-04-24)

Note: Version bump only for package @lerna/exec

3.0.0-beta.17 (2018-04-13)

Note: Version bump only for package @lerna/exec

3.0.0-beta.15 (2018-04-09)

Note: Version bump only for package @lerna/exec

3.0.0-beta.14 (2018-04-03)

Bug Fixes

  • logging: Log failures from package scripts once, not twice (436cfe1)

3.0.0-beta.13 (2018-03-31)

Bug Fixes

  • Use ValidationError instead of Error (bea6bc3)

Features

  • Enable progress bars only when necessary (b766c83)

3.0.0-beta.12 (2018-03-30)

Features

3.0.0-beta.11 (2018-03-29)

Bug Fixes

  • exec: Clarify --no-bail option (6e4c6fd)

3.0.0-beta.10 (2018-03-27)

Features

  • commands: Delay require of command instantiation (a1284f3)

BREAKING CHANGES

  • commands: The default export of command packages is now a factory, not the subclass (which is now a named export).

3.0.0-beta.9 (2018-03-24)

Features

  • command: Rename this.repository -> this.project (43e98a0)

3.0.0-beta.7 (2018-03-20)

Note: Version bump only for package @lerna/exec

3.0.0-beta.4 (2018-03-19)

Note: Version bump only for package @lerna/exec

3.0.0-beta.3 (2018-03-15)

Note: Version bump only for package @lerna/exec

3.0.0-beta.2 (2018-03-10)

Note: Version bump only for package @lerna/exec

3.0.0-beta.1 (2018-03-09)

Bug Fixes

  • filter-options: require a git repo when using --since (d21b66e), closes #822