concurrently
Advanced tools
Comparing version 5.3.0 to 8.2.0
63
index.js
@@ -1,58 +0,9 @@ | ||
const InputHandler = require('./src/flow-control/input-handler'); | ||
const KillOnSignal = require('./src/flow-control/kill-on-signal'); | ||
const KillOthers = require('./src/flow-control/kill-others'); | ||
const LogError = require('./src/flow-control/log-error'); | ||
const LogExit = require('./src/flow-control/log-exit'); | ||
const LogOutput = require('./src/flow-control/log-output'); | ||
const RestartProcess = require('./src/flow-control/restart-process'); | ||
/* | ||
* While in local development, make sure you've run `pnpm run build` first. | ||
*/ | ||
const concurrently = require('./src/concurrently'); | ||
const Logger = require('./src/logger'); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const concurrently = require('./dist/src/index.js'); | ||
module.exports = (commands, options = {}) => { | ||
const logger = new Logger({ | ||
outputStream: options.outputStream || process.stdout, | ||
prefixFormat: options.prefix, | ||
prefixLength: options.prefixLength, | ||
raw: options.raw, | ||
timestampFormat: options.timestampFormat, | ||
}); | ||
return concurrently(commands, { | ||
maxProcesses: options.maxProcesses, | ||
raw: options.raw, | ||
successCondition: options.successCondition, | ||
controllers: [ | ||
new LogError({ logger }), | ||
new LogOutput({ logger }), | ||
new LogExit({ logger }), | ||
new InputHandler({ | ||
logger, | ||
defaultInputTarget: options.defaultInputTarget, | ||
inputStream: options.inputStream, | ||
}), | ||
new KillOnSignal({ process }), | ||
new RestartProcess({ | ||
logger, | ||
delay: options.restartDelay, | ||
tries: options.restartTries, | ||
}), | ||
new KillOthers({ | ||
logger, | ||
conditions: options.killOthers | ||
}) | ||
] | ||
}); | ||
}; | ||
// Export all flow controllers and the main concurrently function, | ||
// so that 3rd-parties can use them however they want | ||
exports.concurrently = concurrently; | ||
exports.Logger = Logger; | ||
exports.InputHandler = InputHandler; | ||
exports.KillOnSignal = KillOnSignal; | ||
exports.KillOthers = KillOthers; | ||
exports.LogError = LogError; | ||
exports.LogExit = LogExit; | ||
exports.LogOutput = LogOutput; | ||
exports.RestartProcess = RestartProcess; | ||
module.exports = exports = concurrently.default; | ||
Object.assign(exports, concurrently); |
107
package.json
{ | ||
"name": "concurrently", | ||
"version": "5.3.0", | ||
"version": "8.2.0", | ||
"description": "Run commands concurrently", | ||
"main": "index.js", | ||
"types": "dist/src/index.d.ts", | ||
"type": "commonjs", | ||
"bin": { | ||
"concurrently": "./bin/concurrently.js" | ||
"concurrently": "./dist/bin/concurrently.js", | ||
"conc": "./dist/bin/concurrently.js" | ||
}, | ||
"engines": { | ||
"node": ">=6.0.0" | ||
"node": "^14.13.0 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"lint": "eslint . --ignore-path .gitignore", | ||
"report-coverage": "cat coverage/lcov.info | coveralls", | ||
"test": "jest" | ||
"exports": { | ||
".": { | ||
"types": "./dist/src/index.d.ts", | ||
"import": "./index.mjs", | ||
"require": "./index.js", | ||
"default": "./index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/kimmobrunfeldt/concurrently.git" | ||
"url": "https://github.com/open-cli-tools/concurrently.git" | ||
}, | ||
"funding": "https://github.com/open-cli-tools/concurrently?sponsor=1", | ||
"keywords": [ | ||
@@ -32,36 +40,65 @@ "bash", | ||
"dependencies": { | ||
"chalk": "^2.4.2", | ||
"date-fns": "^2.0.1", | ||
"lodash": "^4.17.15", | ||
"read-pkg": "^4.0.1", | ||
"rxjs": "^6.5.2", | ||
"spawn-command": "^0.0.2-1", | ||
"supports-color": "^6.1.0", | ||
"chalk": "^4.1.2", | ||
"date-fns": "^2.30.0", | ||
"lodash": "^4.17.21", | ||
"rxjs": "^7.8.1", | ||
"shell-quote": "^1.8.1", | ||
"spawn-command": "0.0.2", | ||
"supports-color": "^8.1.1", | ||
"tree-kill": "^1.2.2", | ||
"yargs": "^13.3.0" | ||
"yargs": "^17.7.2" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^3.0.4", | ||
"eslint": "^5.16.0", | ||
"jest": "^24.8.0", | ||
"jest-create-mock-instance": "^1.1.0" | ||
"@hirez_io/observer-spy": "^2.2.0", | ||
"@swc/core": "^1.3.62", | ||
"@swc/jest": "^0.2.26", | ||
"@types/jest": "^29.5.2", | ||
"@types/lodash": "^4.14.195", | ||
"@types/node": "^14.18.48", | ||
"@types/shell-quote": "^1.7.1", | ||
"@types/supports-color": "^8.1.1", | ||
"@types/yargs": "^17.0.24", | ||
"@typescript-eslint/eslint-plugin": "^5.59.9", | ||
"@typescript-eslint/parser": "^5.59.9", | ||
"coveralls-next": "^4.2.0", | ||
"ctrlc-wrapper": "^0.0.4", | ||
"esbuild": "~0.17.19", | ||
"eslint": "^8.42.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-jest": "^27.2.1", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-simple-import-sort": "^10.0.0", | ||
"husky": "^8.0.3", | ||
"jest": "^29.5.0", | ||
"jest-create-mock-instance": "^2.0.0", | ||
"lint-staged": "^13.2.2", | ||
"prettier": "^2.8.8", | ||
"safe-publish-latest": "^2.0.0", | ||
"string-argv": "^0.3.2", | ||
"typescript": "~5.1.3" | ||
}, | ||
"files": [ | ||
"bin", | ||
"dist", | ||
"index.js", | ||
"index.mjs", | ||
"!**/fixtures", | ||
"index.js", | ||
"src", | ||
"!*.spec.js" | ||
"!**/*.spec.js", | ||
"!**/*.spec.d.ts" | ||
], | ||
"jest": { | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"src/**/*.js" | ||
], | ||
"coveragePathIgnorePatterns": [ | ||
"/fixtures/", | ||
"/node_modules/" | ||
], | ||
"testEnvironment": "node" | ||
"lint-staged": { | ||
"*.?(m){js,ts}": "eslint --fix", | ||
"*.{json,y?(a)ml,md}": "prettier --write" | ||
}, | ||
"scripts": { | ||
"build": "tsc --build", | ||
"postbuild": "chmod +x dist/bin/concurrently.js", | ||
"clean": "tsc --build --clean", | ||
"format": "prettier --check '**/*.{json,y?(a)ml,md}'", | ||
"format:fix": "pnpm run format --write", | ||
"lint": "eslint --ignore-path .gitignore --ext mjs,js,ts .", | ||
"lint:fix": "pnpm run lint --fix", | ||
"report-coverage": "cat coverage/lcov.info | coveralls", | ||
"test": "jest" | ||
} | ||
} | ||
} |
355
README.md
@@ -1,22 +0,29 @@ | ||
# Concurrently | ||
# concurrently | ||
[![Travis Build Status](https://travis-ci.org/kimmobrunfeldt/concurrently.svg)](https://travis-ci.org/kimmobrunfeldt/concurrently) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/kimmobrunfeldt/concurrently?branch=master&svg=true)](https://ci.appveyor.com/project/kimmobrunfeldt/concurrently) *master branch status* | ||
[![Latest Release](https://img.shields.io/github/v/release/open-cli-tools/concurrently?label=Release)](https://github.com/open-cli-tools/concurrently/releases) | ||
[![License](https://img.shields.io/github/license/open-cli-tools/concurrently?label=License)](https://github.com/open-cli-tools/concurrently/blob/main/LICENSE) | ||
[![Weekly Downloads on NPM](https://img.shields.io/npm/dw/concurrently?label=Downloads&logo=npm)](https://www.npmjs.com/package/concurrently) | ||
[![CI Status](https://img.shields.io/github/actions/workflow/status/open-cli-tools/concurrently/test.yml?label=CI&logo=github)](https://github.com/open-cli-tools/concurrently/actions/workflows/test.yml) | ||
[![Coverage Status](https://img.shields.io/coveralls/github/open-cli-tools/concurrently/main?label=Coverage&logo=coveralls)](https://coveralls.io/github/open-cli-tools/concurrently?branch=main) | ||
[![NPM Badge](https://nodei.co/npm/concurrently.png?downloads=true)](https://www.npmjs.com/package/concurrently) | ||
Run multiple commands concurrently. | ||
Like `npm run watch-js & npm run watch-less` but better. | ||
![](docs/demo.gif) | ||
![Demo](docs/demo.gif) | ||
**Table of contents** | ||
- [Why](#why) | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [Programmatic Usage](#programmatic-usage) | ||
- [FAQ](#faq) | ||
**Table of Contents** | ||
- [concurrently](#concurrently) | ||
- [Why](#why) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [API](#api) | ||
- [`concurrently(commands[, options])`](#concurrentlycommands-options) | ||
- [`Command`](#command) | ||
- [`CloseEvent`](#closeevent) | ||
- [FAQ](#faq) | ||
## Why | ||
I like [task automation with npm](http://substack.net/task_automation_with_npm_run) | ||
I like [task automation with npm](https://web.archive.org/web/20220531064025/https://github.com/substack/blog/blob/master/npm_run.markdown) | ||
but the usual way to run multiple commands concurrently is | ||
@@ -32,24 +39,27 @@ `npm run watch-js & npm run watch-css`. That's fine but it's hard to keep | ||
* Cross platform (including Windows) | ||
* Output is easy to follow with prefixes | ||
* With `--kill-others` switch, all commands are killed if one dies | ||
* Spawns commands with [spawn-command](https://github.com/mmalecki/spawn-command) | ||
- Cross platform (including Windows) | ||
- Output is easy to follow with prefixes | ||
- With `--kill-others` switch, all commands are killed if one dies | ||
- Spawns commands with [spawn-command](https://github.com/mmalecki/spawn-command) | ||
## Install | ||
## Installation | ||
The tool is written in Node.js, but you can use it to run **any** commands. | ||
**concurrently** can be installed in the global scope (if you'd like to have it available and use it on the whole system) or locally for a specific package (for example if you'd like to use it in the `scripts` section of your package): | ||
```bash | ||
npm install -g concurrently | ||
``` | ||
| | npm | Yarn | pnpm | Bun | | ||
| ----------- | ----------------------- | ------------------------------ | -------------------------- | ------------------------- | | ||
| **Global** | `npm i -g concurrently` | `yarn global add concurrently` | `pnpm add -g concurrently` | `bun add -g concurrently` | | ||
| **Local**\* | `npm i -D concurrently` | `yarn add -D concurrently` | `pnpm add -D concurrently` | `bun add -d concurrently` | | ||
or if you are using it from npm scripts: | ||
<sub>\* It's recommended to add **concurrently** to `devDependencies` as it's usually used for developing purposes. Please adjust the command if this doesn't apply in your case.</sub> | ||
```bash | ||
npm install concurrently --save | ||
``` | ||
## Usage | ||
> **Note** | ||
> The `concurrently` command is now also available under the shorthand alias `conc`. | ||
The tool is written in Node.js, but you can use it to run **any** commands. | ||
Remember to surround separate commands with quotes: | ||
```bash | ||
@@ -80,13 +90,13 @@ concurrently "command1 arg" "command2 arg" | ||
```javascript | ||
```jsonc | ||
{ | ||
//... | ||
"scripts": { | ||
// ... | ||
"watch-js": "...", | ||
"watch-css": "...", | ||
"watch-node": "...", | ||
// ... | ||
}, | ||
//... | ||
"scripts": { | ||
// ... | ||
"watch-js": "...", | ||
"watch-css": "...", | ||
"watch-node": "..." | ||
// ... | ||
} | ||
// ... | ||
} | ||
@@ -109,2 +119,24 @@ ``` | ||
Exclusion is also supported. Given the following scripts in package.json: | ||
```jsonc | ||
{ | ||
// ... | ||
"scripts": { | ||
"lint:js": "...", | ||
"lint:ts": "...", | ||
"lint:fix:js": "...", | ||
"lint:fix:ts": "..." | ||
// ... | ||
} | ||
// ... | ||
} | ||
``` | ||
```bash | ||
# Running only lint:js and lint:ts | ||
# with lint:fix:js and lint:fix:ts excluded | ||
concurrently "npm:lint:*(!fix)" | ||
``` | ||
Good frontend one-liner example [here](https://github.com/kimmobrunfeldt/dont-copy-paste-this-frontend-template/blob/5cd2bde719654941bdfc0a42c6f1b8e69ae79980/package.json#L9). | ||
@@ -115,21 +147,40 @@ | ||
``` | ||
concurrently [options] <command ...> | ||
General | ||
-m, --max-processes How many processes should run at once. | ||
New processes only spawn after all restart tries of a | ||
process. [number] | ||
-n, --names List of custom names to be used in prefix template. | ||
Example names: "main,browser,server" [string] | ||
--name-separator The character to split <names> on. Example usage: | ||
concurrently -n "styles|scripts|server" --name-separator | ||
"|" [default: ","] | ||
-r, --raw Output only raw output of processes, disables prettifying | ||
and concurrently coloring. [boolean] | ||
-s, --success Return exit code of zero or one based on the success or | ||
failure of the "first" child to terminate, the "last | ||
child", or succeed only if "all" child processes succeed. | ||
[choices: "first", "last", "all"] [default: "all"] | ||
--no-color Disables colors from logging [boolean] | ||
-m, --max-processes How many processes should run at once. | ||
Exact number or a percent of CPUs available (for example "50%"). | ||
New processes only spawn after all restart tries | ||
of a process. [string] | ||
-n, --names List of custom names to be used in prefix | ||
template. | ||
Example names: "main,browser,server" [string] | ||
--name-separator The character to split <names> on. Example usage: | ||
-n "styles|scripts|server" --name-separator "|" | ||
[default: ","] | ||
-s, --success Which command(s) must exit with code 0 in order | ||
for concurrently exit with code 0 too. Options | ||
are: | ||
- "first" for the first command to exit; | ||
- "last" for the last command to exit; | ||
- "all" for all commands; | ||
- "command-{name}"/"command-{index}" for the | ||
commands with that name or index; | ||
- "!command-{name}"/"!command-{index}" for all | ||
commands but the ones with that name or index. | ||
[default: "all"] | ||
-r, --raw Output only raw output of processes, disables | ||
prettifying and concurrently coloring. [boolean] | ||
--no-color Disables colors from logging [boolean] | ||
--hide Comma-separated list of processes to hide the | ||
output. | ||
The processes can be identified by their name or | ||
index. [string] [default: ""] | ||
-g, --group Order the output as if the commands were run | ||
sequentially. [boolean] | ||
--timings Show timing information for all processes. | ||
[boolean] [default: false] | ||
-P, --passthrough-arguments Passthrough additional arguments to commands | ||
(accessible via placeholders) instead of treating | ||
them as commands. [boolean] [default: false] | ||
@@ -147,7 +198,9 @@ Prefix styling | ||
- Available colors: black, red, green, yellow, blue, | ||
magenta, cyan, white, gray | ||
magenta, cyan, white, gray, | ||
any hex values for colors (e.g. #23de43) or auto for | ||
an automatically picked color | ||
- Available background colors: bgBlack, bgRed, | ||
bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite | ||
See https://www.npmjs.com/package/chalk for more | ||
information. [string] [default: "gray.dim"] | ||
information. [string] [default: "reset"] | ||
-l, --prefix-length Limit how many characters of the command is displayed | ||
@@ -161,18 +214,23 @@ in prefix. The option can be used to shorten the | ||
Input handling | ||
-i, --handle-input Whether input should be forwarded to the child | ||
processes. See examples for more information.[boolean] | ||
--default-input-target Identifier for child process to which input on stdin | ||
should be sent if not specified at start of input. | ||
Can be either the index or the name of the process. | ||
[default: 0] | ||
-i, --handle-input Whether input should be forwarded to the child | ||
processes. See examples for more information. | ||
[boolean] | ||
--default-input-target Identifier for child process to which input on | ||
stdin should be sent if not specified at start of | ||
input. | ||
Can be either the index or the name of the | ||
process. [default: 0] | ||
Killing other processes | ||
-k, --kill-others kill other processes if one exits or dies [boolean] | ||
--kill-others-on-fail kill other processes if one exits with non zero status | ||
code [boolean] | ||
-k, --kill-others Kill other processes if one exits or dies.[boolean] | ||
--kill-others-on-fail Kill other processes if one exits with non zero | ||
status code. [boolean] | ||
--kill-signal Signal to send to other processes if one exits or dies. | ||
(SIGTERM/SIGKILL, defaults to SIGTERM) [string] | ||
Restarting | ||
--restart-tries How many times a process that died should restart. | ||
--restart-tries How many times a process that died should restart. | ||
Negative numbers will make the process restart forever. | ||
[number] [default: 0] | ||
--restart-after Delay time to respawn the process, in milliseconds. | ||
--restart-after Delay time to respawn the process, in milliseconds. | ||
[number] [default: 0] | ||
@@ -184,2 +242,3 @@ | ||
Examples: | ||
@@ -204,2 +263,15 @@ | ||
- Auto varying colored prefixes | ||
$ concurrently -c "auto" "npm run watch" "http-server" | ||
- Mixing auto and manual colored prefixes | ||
$ concurrently -c "red,auto" "npm run watch" "http-server" "echo hello" | ||
- Configuring via environment variables with CONCURRENTLY_ prefix | ||
$ CONCURRENTLY_RAW=true CONCURRENTLY_KILL_OTHERS=true concurrently "echo | ||
hello" "echo world" | ||
- Send input to default | ||
@@ -224,44 +296,72 @@ | ||
- Shortened NPM run command with wildcard | ||
- Shortened NPM run command with wildcard (make sure to wrap it in quotes!) | ||
$ concurrently npm:watch-* | ||
$ concurrently "npm:watch-*" | ||
For more details, visit https://github.com/kimmobrunfeldt/concurrently | ||
- Exclude patterns so that between "lint:js" and "lint:fix:js", only "lint:js" | ||
is ran | ||
$ concurrently "npm:*(!fix)" | ||
- Passthrough some additional arguments via '{<number>}' placeholder | ||
$ concurrently -P "echo {1}" -- foo | ||
- Passthrough all additional arguments via '{@}' placeholder | ||
$ concurrently -P "npm:dev-* -- {@}" -- --watch --noEmit | ||
- Passthrough all additional arguments combined via '{*}' placeholder | ||
$ concurrently -P "npm:dev-* -- {*}" -- --watch --noEmit | ||
For more details, visit https://github.com/open-cli-tools/concurrently | ||
``` | ||
## Programmatic Usage | ||
concurrently can be used programmatically by using the API documented below: | ||
## API | ||
**concurrently** can be used programmatically by using the API documented below: | ||
### `concurrently(commands[, options])` | ||
- `commands`: an array of either strings (containing the commands to run) or objects | ||
with the shape `{ command, name, prefixColor, env }`. | ||
with the shape `{ command, name, prefixColor, env, cwd }`. | ||
- `options` (optional): an object containing any of the below: | ||
- `defaultInputTarget`: the default input target when reading from `inputStream`. | ||
- `cwd`: the working directory to be used by all commands. Can be overriden per command. | ||
Default: `process.cwd()`. | ||
- `defaultInputTarget`: the default input target when reading from `inputStream`. | ||
Default: `0`. | ||
- `inputStream`: a [`Readable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_readable_streams) | ||
to read the input from, eg `process.stdin`. | ||
- `killOthers`: an array of exitting conditions that will cause a process to kill others. | ||
- `handleInput`: when `true`, reads input from `process.stdin`. | ||
- `inputStream`: a [`Readable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_readable_streams) | ||
to read the input from. Should only be used in the rare instance you would like to stream anything other than `process.stdin`. Overrides `handleInput`. | ||
- `pauseInputStreamOnFinish`: by default, pauses the input stream (`process.stdin` when `handleInput` is enabled, or `inputStream` if provided) when all of the processes have finished. If you need to read from the input stream after `concurrently` has finished, set this to `false`. ([#252](https://github.com/kimmobrunfeldt/concurrently/issues/252)). | ||
- `killOthers`: an array of exitting conditions that will cause a process to kill others. | ||
Can contain any of `success` or `failure`. | ||
- `maxProcesses`: how many processes should run at once. | ||
- `outputStream`: a [`Writable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_writable_streams) | ||
- `maxProcesses`: how many processes should run at once. | ||
- `outputStream`: a [`Writable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_writable_streams) | ||
to write logs to. Default: `process.stdout`. | ||
- `prefix`: the prefix type to use when logging processes output. | ||
Possible values: `index`, `pid`, `time`, `command`, `name`, `none`, or a template (eg `[{time} process: {pid}]`). | ||
Default: the name of the process, or its index if no name is set. | ||
- `prefixLength`: how many characters to show when prefixing with `command`. Default: `10` | ||
- `raw`: whether raw mode should be used, meaning strictly process output will | ||
be logged, without any prefixes, colouring or extra stuff. | ||
- `successCondition`: the condition to consider the run was successful. | ||
- `prefix`: the prefix type to use when logging processes output. | ||
Possible values: `index`, `pid`, `time`, `command`, `name`, `none`, or a template (eg `[{time} process: {pid}]`). | ||
Default: the name of the process, or its index if no name is set. | ||
- `prefixColors`: a list of colors as supported by [chalk](https://www.npmjs.com/package/chalk) or `auto` for an automatically picked color. | ||
If concurrently would run more commands than there are colors, the last color is repeated, unless if the last color value is `auto` which means following colors are automatically picked to vary. | ||
Prefix colors specified per-command take precedence over this list. | ||
- `prefixLength`: how many characters to show when prefixing with `command`. Default: `10` | ||
- `raw`: whether raw mode should be used, meaning strictly process output will | ||
be logged, without any prefixes, coloring or extra stuff. Can be overriden per command. | ||
- `successCondition`: the condition to consider the run was successful. | ||
If `first`, only the first process to exit will make up the success of the run; if `last`, the last process that exits will determine whether the run succeeds. | ||
Anything else means all processes should exit successfully. | ||
- `restartTries`: how many attempts to restart a process that dies will be made. Default: `0`. | ||
- `restartDelay`: how many milliseconds to wait between process restarts. Default: `0`. | ||
- `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format) | ||
- `restartTries`: how many attempts to restart a process that dies will be made. Default: `0`. | ||
- `restartDelay`: how many milliseconds to wait between process restarts. Default: `0`. | ||
- `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format) | ||
to use when prefixing with `time`. Default: `yyyy-MM-dd HH:mm:ss.ZZZ` | ||
- `additionalArguments`: list of additional arguments passed that will get replaced in each command. If not defined, no argument replacing will happen. | ||
> Returns: a `Promise` that resolves if the run was successful (according to `successCondition` option), | ||
> or rejects, containing an array of objects with information for each command that has been run, in the order | ||
> that the commands terminated. The objects have the shape `{ command, index, exitCode }`, where `command` is the object | ||
> passed in the `commands` array and `index` its index there. Default values (empty strings or objects) are returned for | ||
> the fields that were not specified. | ||
> **Returns:** an object in the shape `{ result, commands }`. | ||
> | ||
> - `result`: a `Promise` that resolves if the run was successful (according to `successCondition` option), | ||
> or rejects, containing an array of [`CloseEvent`](#CloseEvent), in the order that the commands terminated. | ||
> - `commands`: an array of all spawned [`Command`s](#Command). | ||
@@ -272,30 +372,73 @@ Example: | ||
const concurrently = require('concurrently'); | ||
concurrently([ | ||
const { result } = concurrently( | ||
[ | ||
'npm:watch-*', | ||
{ command: 'nodemon', name: 'server' }, | ||
{ command: 'deploy', name: 'deploy', env: { PUBLIC_KEY: '...' } } | ||
], { | ||
{ command: 'deploy', name: 'deploy', env: { PUBLIC_KEY: '...' } }, | ||
{ | ||
command: 'watch', | ||
name: 'watch', | ||
cwd: path.resolve(__dirname, 'scripts/watchers'), | ||
}, | ||
], | ||
{ | ||
prefix: 'name', | ||
killOthers: ['failure', 'success'], | ||
restartTries: 3, | ||
}).then(success, failure); | ||
cwd: path.resolve(__dirname, 'scripts'), | ||
} | ||
); | ||
result.then(success, failure); | ||
``` | ||
### `Command` | ||
An object that contains all information about a spawned command, and ways to interact with it.<br> | ||
It has the following properties: | ||
- `index`: the index of the command among all commands spawned. | ||
- `command`: the command line of the command. | ||
- `name`: the name of the command; defaults to an empty string. | ||
- `cwd`: the current working directory of the command. | ||
- `env`: an object with all the environment variables that the command will be spawned with. | ||
- `killed`: whether the command has been killed. | ||
- `exited`: whether the command exited yet. | ||
- `pid`: the command's process ID. | ||
- `stdin`: a Writable stream to the command's `stdin`. | ||
- `stdout`: an RxJS observable to the command's `stdout`. | ||
- `stderr`: an RxJS observable to the command's `stderr`. | ||
- `error`: an RxJS observable to the command's error events (e.g. when it fails to spawn). | ||
- `timer`: an RxJS observable to the command's timing events (e.g. starting, stopping). | ||
- `close`: an RxJS observable to the command's close events. | ||
See [`CloseEvent`](#CloseEvent) for more information. | ||
- `start()`: starts the command, setting up all | ||
- `kill([signal])`: kills the command, optionally specifying a signal (e.g. `SIGTERM`, `SIGKILL`, etc). | ||
### `CloseEvent` | ||
An object with information about a command's closing event.<br> | ||
It contains the following properties: | ||
- `command`: a stripped down version of [`Command`](#command), including only `name`, `command`, `env` and `cwd` properties. | ||
- `index`: the index of the command among all commands spawned. | ||
- `killed`: whether the command exited because it was killed. | ||
- `exitCode`: the exit code of the command's process, or the signal which it was killed with. | ||
- `timings`: an object in the shape `{ startDate, endDate, durationSeconds }`. | ||
## FAQ | ||
* Process exited with code *null*? | ||
- Process exited with code _null_? | ||
From [Node child_process documentation](http://nodejs.org/api/child_process.html#child_process_event_exit), `exit` event: | ||
From [Node child_process documentation](http://nodejs.org/api/child_process.html#child_process_event_exit), `exit` event: | ||
> This event is emitted after the child process ends. If the process | ||
> terminated normally, code is the final exit code of the process, | ||
> otherwise null. If the process terminated due to receipt of a signal, | ||
> signal is the string name of the signal, otherwise null. | ||
> This event is emitted after the child process ends. If the process | ||
> terminated normally, code is the final exit code of the process, | ||
> otherwise null. If the process terminated due to receipt of a signal, | ||
> signal is the string name of the signal, otherwise null. | ||
So _null_ means the process didn't terminate normally. This will make **concurrently** | ||
to return non-zero exit code too. | ||
So *null* means the process didn't terminate normally. This will make **concurrent** | ||
to return non-zero exit code too. | ||
- Does this work with the npm-replacements [yarn](https://github.com/yarnpkg/yarn), [pnpm](https://pnpm.js.org/), or [Bun](https://bun.sh/)? | ||
* Does this work with the npm-replacements [yarn](https://github.com/yarnpkg/yarn) or [pnpm](https://pnpm.js.org/)? | ||
Yes! In all examples above, you may replace "`npm`" with "`yarn`" or "`pnpm`". | ||
Yes! In all examples above, you may replace "`npm`" with "`yarn`", "`pnpm`", or "`bun`". |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
120621
55
2499
435
28
+ Addedshell-quote@^1.8.1
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedrxjs@7.8.1(transitive)
+ Addedshell-quote@1.8.1(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedsupports-color@7.2.08.1.1(transitive)
+ Addedtslib@2.7.0(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)
- Removedread-pkg@^4.0.1
- Removedansi-regex@4.1.1(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcliui@5.0.0(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removedemoji-regex@7.0.3(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedfind-up@3.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-fullwidth-code-point@2.0.0(transitive)
- Removedjson-parse-better-errors@1.0.2(transitive)
- Removedlocate-path@3.0.0(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@3.0.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedparse-json@4.0.0(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpify@3.0.0(transitive)
- Removedread-pkg@4.0.1(transitive)
- Removedrequire-main-filename@2.0.0(transitive)
- Removedresolve@1.22.8(transitive)
- Removedrxjs@6.6.7(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedstring-width@3.1.0(transitive)
- Removedstrip-ansi@5.2.0(transitive)
- Removedsupports-color@5.5.06.1.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtslib@1.14.1(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedwhich-module@2.0.1(transitive)
- Removedwrap-ansi@5.1.0(transitive)
- Removedy18n@4.0.3(transitive)
- Removedyargs@13.3.2(transitive)
- Removedyargs-parser@13.1.2(transitive)
Updatedchalk@^4.1.2
Updateddate-fns@^2.30.0
Updatedlodash@^4.17.21
Updatedrxjs@^7.8.1
Updatedspawn-command@0.0.2
Updatedsupports-color@^8.1.1
Updatedyargs@^17.7.2