@lerna/exec
Advanced tools
Comparing version 3.0.0-beta.21 to 3.0.0-rc.0
@@ -6,2 +6,17 @@ # Change Log | ||
<a name="3.0.0-rc.0"></a> | ||
# [3.0.0-rc.0](https://github.com/lerna/lerna/compare/v3.0.0-beta.21...v3.0.0-rc.0) (2018-07-27) | ||
### Features | ||
* Add description from --help summary [skip ci] ([9b65d8e](https://github.com/lerna/lerna/commit/9b65d8e)) | ||
* **cli:** Upgrade to Yargs 12 ([7899ab8](https://github.com/lerna/lerna/commit/7899ab8)) | ||
* **command:** Remove .defaultOptions() from option resolution stack ([2b27a54](https://github.com/lerna/lerna/commit/2b27a54)) | ||
* Count packages affected in command summary logging ([5f5e585](https://github.com/lerna/lerna/commit/5f5e585)) | ||
<a name="3.0.0-beta.21"></a> | ||
@@ -8,0 +23,0 @@ # [3.0.0-beta.21](https://github.com/lerna/lerna/compare/v3.0.0-beta.20...v3.0.0-beta.21) (2018-05-12) |
@@ -10,3 +10,3 @@ "use strict"; | ||
exports.describe = "Run an arbitrary command in each package."; | ||
exports.describe = "Run an arbitrary command in each package"; | ||
@@ -29,5 +29,4 @@ exports.builder = yargs => { | ||
describe: "Stop when the command fails in a package.\nPass --no-bail to continue despite failure.", | ||
defaultDescription: "true", | ||
default: true, | ||
type: "boolean", | ||
default: undefined, | ||
}, | ||
@@ -38,3 +37,2 @@ stream: { | ||
type: "boolean", | ||
default: undefined, | ||
}, | ||
@@ -45,3 +43,2 @@ parallel: { | ||
type: "boolean", | ||
default: undefined, | ||
}, | ||
@@ -53,5 +50,4 @@ // This option controls prefix for stream output so that it can be disabled to be friendly | ||
describe: "Pass --no-prefix to disable prefixing of streamed output.", | ||
defaultDescription: "true", | ||
default: true, | ||
type: "boolean", | ||
default: undefined, | ||
}, | ||
@@ -58,0 +54,0 @@ }); |
33
index.js
@@ -20,10 +20,2 @@ "use strict"; | ||
get defaultOptions() { | ||
return Object.assign({}, super.defaultOptions, { | ||
bail: true, | ||
parallel: false, | ||
prefix: true, | ||
}); | ||
} | ||
initialize() { | ||
@@ -39,2 +31,8 @@ const dashedArgs = this.options["--"] || []; | ||
this.count = this.filteredPackages.length; | ||
// inverted boolean options | ||
this.bail = this.options.bail !== false; | ||
this.prefix = this.options.prefix !== false; | ||
// accessing properties of process.env can be expensive, | ||
@@ -58,3 +56,11 @@ // so cache it here to reduce churn during tighter loops | ||
return runParallelBatches(this.batchedPackages, this.concurrency, runner); | ||
return runParallelBatches(this.batchedPackages, this.concurrency, runner).then(() => { | ||
this.logger.success( | ||
"exec", | ||
"Executed command in %d %s: %j", | ||
this.count, | ||
this.count === 1 ? "package" : "packages", | ||
[this.command].concat(this.args).join(" ") | ||
); | ||
}); | ||
} | ||
@@ -71,3 +77,3 @@ | ||
}), | ||
reject: this.options.bail, | ||
reject: this.bail, | ||
pkg, | ||
@@ -80,4 +86,5 @@ }; | ||
"exec", | ||
"in %d package(s): %s", | ||
this.filteredPackages.length, | ||
"in %d %s: %j", | ||
this.count, | ||
this.count === 1 ? "package" : "packages", | ||
[this.command].concat(this.args).join(" ") | ||
@@ -94,3 +101,3 @@ ); | ||
this.getOpts(pkg), | ||
this.options.prefix && pkg.name | ||
this.prefix && pkg.name | ||
); | ||
@@ -97,0 +104,0 @@ } |
{ | ||
"name": "@lerna/exec", | ||
"version": "3.0.0-beta.21", | ||
"description": "TODO", | ||
"version": "3.0.0-rc.0", | ||
"description": "Run an arbitrary command in each package", | ||
"keywords": [ | ||
@@ -37,10 +37,10 @@ "lerna", | ||
"dependencies": { | ||
"@lerna/batch-packages": "^3.0.0-beta.18", | ||
"@lerna/child-process": "^3.0.0-beta.21", | ||
"@lerna/command": "^3.0.0-beta.21", | ||
"@lerna/filter-options": "^3.0.0-beta.18", | ||
"@lerna/run-parallel-batches": "^3.0.0-beta.0", | ||
"@lerna/validation-error": "^3.0.0-beta.10" | ||
"@lerna/batch-packages": "^3.0.0-rc.0", | ||
"@lerna/child-process": "^3.0.0-rc.0", | ||
"@lerna/command": "^3.0.0-rc.0", | ||
"@lerna/filter-options": "^3.0.0-rc.0", | ||
"@lerna/run-parallel-batches": "^3.0.0-rc.0", | ||
"@lerna/validation-error": "^3.0.0-rc.0" | ||
}, | ||
"gitHead": "ce5c4842e5c927beaa13779c6429a8d7c5b5a933" | ||
"gitHead": "1ab24c152d3ff5c2b9453bcaafeb4b5e432b2410" | ||
} |
# `@lerna/exec` | ||
> description TODO | ||
> Run an arbitrary command in each package | ||
## Usage | ||
TODO | ||
```sh | ||
$ 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`: | ||
```sh | ||
$ 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`: | ||
```sh | ||
$ lerna exec -- node \$LERNA_ROOT_PATH/scripts/some-script.js | ||
``` | ||
## Options | ||
`lerna exec` respects the `--concurrency`, `--scope`, and `--ignore` flags (see [Filter Flags](https://www.npmjs.com/package/@lerna/filter-options)). | ||
```sh | ||
$ 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: | ||
```sh | ||
$ 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. | ||
```sh | ||
$ 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. | ||
```sh | ||
$ 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` | ||
```sh | ||
# 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. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14110
6
135
76