Skip to content

Commit

Permalink
Docs: tweaks and add a known limitation of --print-label
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed May 11, 2016
1 parent a0c727f commit 9d050ab
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
21 changes: 16 additions & 5 deletions docs/npm-run-all.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,27 @@ On the other hand, this `npm-run-all` command runs multiple scripts in parallel
### Run scripts sequentially

```
npm-run-all build:html build:js
npm-run-all clean lint build
```

This is same as `npm run build:html && npm run build:js`.
This is same as `npm run clean && npm run lint && npm run build`.

**Note:** If a script exited with non zero code, the following scripts are not run.
If `--continue-on-error` option is given, this behavior will be disabled.

### Run scripts in parallel

```
npm-run-all --parallel watch:html watch:js
npm-run-all --parallel lint build
```

This is similar to `npm run watch:html & npm run watch:js`.
This is similar to `npm run lint & npm run build`.

**Note:** If a script exited with a non-zero code, the other scripts and those descendant processes are killed with `SIGTERM` (On Windows, with `taskkill.exe /F /T`).
**Note1:** If a script exited with a non-zero code, the other scripts and those descendant processes are killed with `SIGTERM` (On Windows, with `taskkill.exe /F /T`).
If `--continue-on-error` option is given, this behavior will be disabled.

**Note2:** `&` operator does not work on Windows' `cmd.exe`. But `npm-run-all --parallel` works fine there.

### Run a mix of sequential and parallel scripts

```
Expand Down Expand Up @@ -152,4 +154,13 @@ The following 2 commands are similar.

When we use a pattern, arguments are forwarded to every matched script.

### Known Limitations

- If `--print-label` option is given, some tools in scripts might stop coloring their output.
Because some coloring library (e.g. [chalk]) will stop coloring if `process.stdout` is not a TTY.
`npm-run-all` changes the `process.stdout` of child processes to a pipe in order to add labels to the head of each line if `--print-label` option is given.<br>
For example, [eslint] stops coloring under `npm-run-all --print-label`. But [eslint] has `--colors` option to force coloring, we can use it.

[glob]: https://www.npmjs.com/package/glob#glob-primer
[chalk]: https://www.npmjs.com/package/chalk
[eslint]: https://www.npmjs.com/package/eslint
13 changes: 12 additions & 1 deletion docs/run-p.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ The `run-p` command is shorter and **available on Windows**.
> npm run lint & npm run build
```

**Note:** If a script exited with a non-zero code, the other scripts and those descendant processes are killed with `SIGTERM` (On Windows, with `taskkill.exe /F /T`).
**Note1:** If a script exited with a non-zero code, the other scripts and those descendant processes are killed with `SIGTERM` (On Windows, with `taskkill.exe /F /T`).
If `--continue-on-error` option is given, this behavior will be disabled.

**Note2:** `&` operator does not work on Windows' `cmd.exe`. But `run-p` works fine there.

### Glob-like pattern matching for script names

We can use [glob]-like patterns to specify npm-scripts.
Expand Down Expand Up @@ -113,4 +115,13 @@ The following 2 commands are similar.

When we use a pattern, arguments are forwarded to every matched script.

### Known Limitations

- If `--print-label` option is given, some tools in scripts might stop coloring their output.
Because some coloring library (e.g. [chalk]) will stop coloring if `process.stdout` is not a TTY.
`run-p` changes the `process.stdout` of child processes to a pipe in order to add labels to the head of each line if `--print-label` option is given.<br>
For example, [eslint] stops coloring under `run-p --print-label`. But [eslint] has `--colors` option to force coloring, we can use it.

[glob]: https://www.npmjs.com/package/glob#glob-primer
[chalk]: https://www.npmjs.com/package/chalk
[eslint]: https://www.npmjs.com/package/eslint
11 changes: 10 additions & 1 deletion docs/run-s.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ The `run-s` command is shorter.
> npm run clean && npm run lint && npm run build
```

If a script exited with a non-zero code, the following scripts are not run.
**Note:** If a script exited with a non-zero code, the following scripts are not run.

### Glob-like pattern matching for script names

Expand Down Expand Up @@ -112,4 +112,13 @@ The following 2 commands are the same.

When we use a pattern, arguments are forwarded to every matched script.

### Known Limitations

- If `--print-label` option is given, some tools in scripts might stop coloring their output.
Because some coloring library (e.g. [chalk]) will stop coloring if `process.stdout` is not a TTY.
`run-s` changes the `process.stdout` of child processes to a pipe in order to add labels to the head of each line if `--print-label` option is given.<br>
For example, [eslint] stops coloring under `run-s --print-label`. But [eslint] has `--colors` option to force coloring, we can use it.

[glob]: https://www.npmjs.com/package/glob#glob-primer
[chalk]: https://www.npmjs.com/package/chalk
[eslint]: https://www.npmjs.com/package/eslint

0 comments on commit 9d050ab

Please sign in to comment.