concurrently 6.5.1 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -43
- package/dist/bin/concurrently.d.ts +2 -0
- package/dist/bin/concurrently.js +218 -0
- package/dist/bin/epilogue.d.ts +1 -0
- package/dist/bin/epilogue.js +81 -0
- package/dist/src/command-parser/command-parser.d.ts +19 -0
- package/dist/src/command-parser/command-parser.js +2 -0
- package/dist/src/command-parser/expand-arguments.d.ts +12 -0
- package/dist/src/command-parser/expand-arguments.js +40 -0
- package/dist/src/command-parser/expand-npm-shortcut.d.ts +8 -0
- package/dist/src/command-parser/expand-npm-shortcut.js +20 -0
- package/dist/src/command-parser/expand-npm-wildcard.d.ts +13 -0
- package/dist/src/command-parser/expand-npm-wildcard.js +82 -0
- package/dist/src/command-parser/strip-quotes.d.ts +10 -0
- package/dist/src/command-parser/strip-quotes.js +18 -0
- package/dist/src/command.d.ts +104 -0
- package/{src → dist/src}/command.js +54 -30
- package/dist/src/completion-listener.d.ts +39 -0
- package/dist/src/completion-listener.js +74 -0
- package/dist/src/concurrently.d.ts +90 -0
- package/dist/src/concurrently.js +124 -0
- package/dist/src/defaults.d.ts +62 -0
- package/dist/src/defaults.js +67 -0
- package/dist/src/flow-control/flow-controller.d.ts +13 -0
- package/dist/src/flow-control/flow-controller.js +2 -0
- package/dist/src/flow-control/input-handler.d.ts +33 -0
- package/dist/src/flow-control/input-handler.js +73 -0
- package/dist/src/flow-control/kill-on-signal.d.ts +17 -0
- package/{src → dist/src}/flow-control/kill-on-signal.js +15 -13
- package/dist/src/flow-control/kill-others.d.ts +18 -0
- package/dist/src/flow-control/kill-others.js +35 -0
- package/dist/src/flow-control/log-error.d.ts +15 -0
- package/dist/src/flow-control/log-error.js +21 -0
- package/dist/src/flow-control/log-exit.d.ts +15 -0
- package/dist/src/flow-control/log-exit.js +19 -0
- package/dist/src/flow-control/log-output.d.ts +15 -0
- package/{src → dist/src}/flow-control/log-output.js +13 -5
- package/dist/src/flow-control/log-timings.d.ts +27 -0
- package/dist/src/flow-control/log-timings.js +88 -0
- package/dist/src/flow-control/restart-process.d.ts +22 -0
- package/dist/src/flow-control/restart-process.js +71 -0
- package/dist/src/get-spawn-opts.d.ts +30 -0
- package/dist/src/get-spawn-opts.js +11 -0
- package/dist/src/index.d.ts +74 -0
- package/dist/src/index.js +70 -0
- package/dist/src/logger.d.ts +72 -0
- package/{src → dist/src}/logger.js +77 -58
- package/dist/src/output-writer.d.ts +19 -0
- package/dist/src/output-writer.js +69 -0
- package/index.js +6 -68
- package/index.mjs +9 -0
- package/package.json +42 -12
- package/bin/concurrently.js +0 -186
- package/bin/concurrently.spec.js +0 -428
- package/bin/epilogue.txt +0 -46
- package/src/command-parser/expand-npm-shortcut.js +0 -13
- package/src/command-parser/expand-npm-shortcut.spec.js +0 -36
- package/src/command-parser/expand-npm-wildcard.js +0 -52
- package/src/command-parser/expand-npm-wildcard.spec.js +0 -104
- package/src/command-parser/strip-quotes.js +0 -12
- package/src/command-parser/strip-quotes.spec.js +0 -20
- package/src/command.spec.js +0 -275
- package/src/completion-listener.js +0 -39
- package/src/completion-listener.spec.js +0 -89
- package/src/concurrently.js +0 -116
- package/src/concurrently.spec.js +0 -199
- package/src/defaults.js +0 -35
- package/src/flow-control/base-handler.js +0 -16
- package/src/flow-control/base-handler.spec.js +0 -22
- package/src/flow-control/input-handler.js +0 -50
- package/src/flow-control/input-handler.spec.js +0 -113
- package/src/flow-control/kill-on-signal.spec.js +0 -79
- package/src/flow-control/kill-others.js +0 -38
- package/src/flow-control/kill-others.spec.js +0 -66
- package/src/flow-control/log-error.js +0 -18
- package/src/flow-control/log-error.spec.js +0 -40
- package/src/flow-control/log-exit.js +0 -11
- package/src/flow-control/log-exit.spec.js +0 -36
- package/src/flow-control/log-output.spec.js +0 -41
- package/src/flow-control/log-timings.js +0 -64
- package/src/flow-control/log-timings.spec.js +0 -137
- package/src/flow-control/restart-process.js +0 -56
- package/src/flow-control/restart-process.spec.js +0 -139
- package/src/get-spawn-opts.js +0 -16
- package/src/get-spawn-opts.spec.js +0 -30
- package/src/logger.spec.js +0 -318
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Concurrently
|
|
2
2
|
|
|
3
|
-
[](https://github.com/open-cli-tools/concurrently/actions?workflow=Tests)
|
|
3
|
+
[](https://github.com/open-cli-tools/concurrently/actions?workflow=Tests)
|
|
4
4
|
[](https://coveralls.io/github/open-cli-tools/concurrently?branch=master)
|
|
5
5
|
|
|
6
6
|
[](https://www.npmjs.com/package/concurrently)
|
|
@@ -15,8 +15,10 @@ Like `npm run watch-js & npm run watch-less` but better.
|
|
|
15
15
|
- [Why](#why)
|
|
16
16
|
- [Install](#install)
|
|
17
17
|
- [Usage](#usage)
|
|
18
|
-
- [
|
|
18
|
+
- [API](#api)
|
|
19
19
|
- [`concurrently(commands[, options])`](#concurrentlycommands-options)
|
|
20
|
+
- [`Command`](#command)
|
|
21
|
+
- [`CloseEvent`](#closeevent)
|
|
20
22
|
- [FAQ](#faq)
|
|
21
23
|
|
|
22
24
|
## Why
|
|
@@ -107,34 +109,68 @@ concurrently -n w: npm:watch-*
|
|
|
107
109
|
concurrently -n w:js,w:css,w:node "npm run watch-js" "npm run watch-css" "npm run watch-node"
|
|
108
110
|
```
|
|
109
111
|
|
|
112
|
+
Exclusion is also supported. Given the following scripts in package.json:
|
|
113
|
+
```javascript
|
|
114
|
+
{
|
|
115
|
+
// ...
|
|
116
|
+
"scripts": {
|
|
117
|
+
"lint:js": "...",
|
|
118
|
+
"lint:ts": "...",
|
|
119
|
+
"lint:fix:js": "...",
|
|
120
|
+
"lint:fix:ts": "...",
|
|
121
|
+
// ...
|
|
122
|
+
}
|
|
123
|
+
// ...
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
```bash
|
|
127
|
+
# Running only lint:js and lint:ts
|
|
128
|
+
# with lint:fix:js and lint:fix:ts excluded
|
|
129
|
+
concurrently "npm:lint:*(!fix)"
|
|
130
|
+
```
|
|
131
|
+
|
|
110
132
|
Good frontend one-liner example [here](https://github.com/kimmobrunfeldt/dont-copy-paste-this-frontend-template/blob/5cd2bde719654941bdfc0a42c6f1b8e69ae79980/package.json#L9).
|
|
111
133
|
|
|
112
134
|
Help:
|
|
113
135
|
|
|
114
136
|
```
|
|
115
|
-
|
|
116
137
|
concurrently [options] <command ...>
|
|
117
138
|
|
|
118
139
|
General
|
|
119
|
-
-m, --max-processes
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
-n, --names
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
140
|
+
-m, --max-processes How many processes should run at once.
|
|
141
|
+
New processes only spawn after all restart tries
|
|
142
|
+
of a process. [number]
|
|
143
|
+
-n, --names List of custom names to be used in prefix
|
|
144
|
+
template.
|
|
145
|
+
Example names: "main,browser,server" [string]
|
|
146
|
+
--name-separator The character to split <names> on. Example usage:
|
|
147
|
+
concurrently -n "styles|scripts|server"
|
|
148
|
+
--name-separator "|" [default: ","]
|
|
149
|
+
-s, --success Which command(s) must exit with code 0 in order
|
|
150
|
+
for concurrently exit with code 0 too. Options
|
|
151
|
+
are:
|
|
152
|
+
- "first" for the first command to exit;
|
|
153
|
+
- "last" for the last command to exit;
|
|
154
|
+
- "all" for all commands;
|
|
155
|
+
- "command-{name}"/"command-{index}" for the
|
|
156
|
+
commands with that name or index;
|
|
157
|
+
- "!command-{name}"/"!command-{index}" for all
|
|
158
|
+
commands but the ones with that name or index.
|
|
159
|
+
[default: "all"]
|
|
160
|
+
-r, --raw Output only raw output of processes, disables
|
|
161
|
+
prettifying and concurrently coloring. [boolean]
|
|
162
|
+
--no-color Disables colors from logging [boolean]
|
|
163
|
+
--hide Comma-separated list of processes to hide the
|
|
164
|
+
output.
|
|
165
|
+
The processes can be identified by their name or
|
|
166
|
+
index. [string] [default: ""]
|
|
167
|
+
-g, --group Order the output as if the commands were run
|
|
168
|
+
sequentially. [boolean]
|
|
169
|
+
--timings Show timing information for all processes.
|
|
170
|
+
[boolean] [default: false]
|
|
171
|
+
-P, --passthrough-arguments Passthrough additional arguments to commands
|
|
172
|
+
(accessible via placeholders) instead of treating
|
|
173
|
+
them as commands. [boolean] [default: false]
|
|
138
174
|
|
|
139
175
|
Prefix styling
|
|
140
176
|
-p, --prefix Prefix used in logging for each process.
|
|
@@ -147,12 +183,12 @@ Prefix styling
|
|
|
147
183
|
- Available modifiers: reset, bold, dim, italic,
|
|
148
184
|
underline, inverse, hidden, strikethrough
|
|
149
185
|
- Available colors: black, red, green, yellow, blue,
|
|
150
|
-
magenta, cyan, white, gray
|
|
151
|
-
colors, eg #23de43
|
|
186
|
+
magenta, cyan, white, gray
|
|
187
|
+
or any hex values for colors, eg #23de43
|
|
152
188
|
- Available background colors: bgBlack, bgRed,
|
|
153
189
|
bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite
|
|
154
190
|
See https://www.npmjs.com/package/chalk for more
|
|
155
|
-
information.
|
|
191
|
+
information. [string] [default: "reset"]
|
|
156
192
|
-l, --prefix-length Limit how many characters of the command is displayed
|
|
157
193
|
in prefix. The option can be used to shorten the
|
|
158
194
|
prefix when it is set to "command"
|
|
@@ -161,17 +197,19 @@ Prefix styling
|
|
|
161
197
|
[string] [default: "yyyy-MM-dd HH:mm:ss.SSS"]
|
|
162
198
|
|
|
163
199
|
Input handling
|
|
164
|
-
-i, --handle-input
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
200
|
+
-i, --handle-input Whether input should be forwarded to the child
|
|
201
|
+
processes. See examples for more information.
|
|
202
|
+
[boolean]
|
|
203
|
+
--default-input-target Identifier for child process to which input on
|
|
204
|
+
stdin should be sent if not specified at start of
|
|
205
|
+
input.
|
|
206
|
+
Can be either the index or the name of the
|
|
207
|
+
process. [default: 0]
|
|
170
208
|
|
|
171
209
|
Killing other processes
|
|
172
|
-
-k, --kill-others
|
|
173
|
-
|
|
174
|
-
|
|
210
|
+
-k, --kill-others Kill other processes if one exits or dies.[boolean]
|
|
211
|
+
--kill-others-on-fail Kill other processes if one exits with non zero
|
|
212
|
+
status code. [boolean]
|
|
175
213
|
|
|
176
214
|
Restarting
|
|
177
215
|
--restart-tries How many times a process that died should restart.
|
|
@@ -184,6 +222,7 @@ Options:
|
|
|
184
222
|
-h, --help Show help [boolean]
|
|
185
223
|
-v, -V, --version Show version number [boolean]
|
|
186
224
|
|
|
225
|
+
|
|
187
226
|
Examples:
|
|
188
227
|
|
|
189
228
|
- Output nothing more than stdout+stderr of child processes
|
|
@@ -205,7 +244,8 @@ Examples:
|
|
|
205
244
|
|
|
206
245
|
- Configuring via environment variables with CONCURRENTLY_ prefix
|
|
207
246
|
|
|
208
|
-
$ CONCURRENTLY_RAW=true CONCURRENTLY_KILL_OTHERS=true concurrently "echo
|
|
247
|
+
$ CONCURRENTLY_RAW=true CONCURRENTLY_KILL_OTHERS=true concurrently "echo
|
|
248
|
+
hello" "echo world"
|
|
209
249
|
|
|
210
250
|
- Send input to default
|
|
211
251
|
|
|
@@ -230,10 +270,27 @@ Examples:
|
|
|
230
270
|
|
|
231
271
|
$ concurrently "npm:watch-*"
|
|
232
272
|
|
|
273
|
+
- Exclude patterns so that between "lint:js" and "lint:fix:js", only "lint:js"
|
|
274
|
+
is ran
|
|
275
|
+
|
|
276
|
+
$ concurrently "npm:*(!fix)"
|
|
277
|
+
|
|
278
|
+
- Passthrough some additional arguments via '{<number>}' placeholder
|
|
279
|
+
|
|
280
|
+
$ concurrently -P "echo {1}" -- foo
|
|
281
|
+
|
|
282
|
+
- Passthrough all additional arguments via '{@}' placeholder
|
|
283
|
+
|
|
284
|
+
$ concurrently -P "npm:dev-* -- {@}" -- --watch --noEmit
|
|
285
|
+
|
|
286
|
+
- Passthrough all additional arguments combined via '{*}' placeholder
|
|
287
|
+
|
|
288
|
+
$ concurrently -P "npm:dev-* -- {*}" -- --watch --noEmit
|
|
289
|
+
|
|
233
290
|
For more details, visit https://github.com/open-cli-tools/concurrently
|
|
234
291
|
```
|
|
235
292
|
|
|
236
|
-
##
|
|
293
|
+
## API
|
|
237
294
|
concurrently can be used programmatically by using the API documented below:
|
|
238
295
|
|
|
239
296
|
### `concurrently(commands[, options])`
|
|
@@ -271,18 +328,18 @@ concurrently can be used programmatically by using the API documented below:
|
|
|
271
328
|
- `restartDelay`: how many milliseconds to wait between process restarts. Default: `0`.
|
|
272
329
|
- `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format)
|
|
273
330
|
to use when prefixing with `time`. Default: `yyyy-MM-dd HH:mm:ss.ZZZ`
|
|
331
|
+
- `additionalArguments`: list of additional arguments passed that will get replaced in each command. If not defined, no argument replacing will happen.
|
|
274
332
|
|
|
275
|
-
> Returns
|
|
276
|
-
>
|
|
277
|
-
>
|
|
278
|
-
>
|
|
279
|
-
> `killOthers`. Default values (empty strings or objects) are returned for the fields that were not specified.
|
|
333
|
+
> **Returns:** an object in the shape `{ result, commands }`.
|
|
334
|
+
> - `result`: a `Promise` that resolves if the run was successful (according to `successCondition` option),
|
|
335
|
+
> or rejects, containing an array of [`CloseEvent`](#CloseEvent), in the order that the commands terminated.
|
|
336
|
+
> - `commands`: an array of all spawned [`Command`s](#Command).
|
|
280
337
|
|
|
281
338
|
Example:
|
|
282
339
|
|
|
283
340
|
```js
|
|
284
341
|
const concurrently = require('concurrently');
|
|
285
|
-
concurrently([
|
|
342
|
+
const { result } = concurrently([
|
|
286
343
|
'npm:watch-*',
|
|
287
344
|
{ command: 'nodemon', name: 'server' },
|
|
288
345
|
{ command: 'deploy', name: 'deploy', env: { PUBLIC_KEY: '...' } },
|
|
@@ -292,9 +349,42 @@ concurrently([
|
|
|
292
349
|
killOthers: ['failure', 'success'],
|
|
293
350
|
restartTries: 3,
|
|
294
351
|
cwd: path.resolve(__dirname, 'scripts'),
|
|
295
|
-
})
|
|
352
|
+
});
|
|
353
|
+
result.then(success, failure);
|
|
296
354
|
```
|
|
297
355
|
|
|
356
|
+
### `Command`
|
|
357
|
+
An object that contains all information about a spawned command, and ways to interact with it.<br>
|
|
358
|
+
It has the following properties:
|
|
359
|
+
|
|
360
|
+
- `index`: the index of the command among all commands spawned.
|
|
361
|
+
- `command`: the command line of the command.
|
|
362
|
+
- `name`: the name of the command; defaults to an empty string.
|
|
363
|
+
- `cwd`: the current working directory of the command.
|
|
364
|
+
- `env`: an object with all the environment variables that the command will be spawned with.
|
|
365
|
+
- `killed`: whether the command has been killed.
|
|
366
|
+
- `exited`: whether the command exited yet.
|
|
367
|
+
- `pid`: the command's process ID.
|
|
368
|
+
- `stdin`: a Writable stream to the command's `stdin`.
|
|
369
|
+
- `stdout`: an RxJS observable to the command's `stdout`.
|
|
370
|
+
- `stderr`: an RxJS observable to the command's `stderr`.
|
|
371
|
+
- `error`: an RxJS observable to the command's error events (e.g. when it fails to spawn).
|
|
372
|
+
- `timer`: an RxJS observable to the command's timing events (e.g. starting, stopping).
|
|
373
|
+
- `close`: an RxJS observable to the command's close events.
|
|
374
|
+
See [`CloseEvent`](#CloseEvent) for more information.
|
|
375
|
+
- `start()`: starts the command, setting up all
|
|
376
|
+
- `kill([signal])`: kills the command, optionally specifying a signal (e.g. `SIGTERM`, `SIGKILL`, etc).
|
|
377
|
+
|
|
378
|
+
### `CloseEvent`
|
|
379
|
+
An object with information about a command's closing event.<br>
|
|
380
|
+
It contains the following properties:
|
|
381
|
+
|
|
382
|
+
- `command`: a stripped down version of [`Command`](#command), including only `name`, `command`, `env` and `cwd` properties.
|
|
383
|
+
- `index`: the index of the command among all commands spawned.
|
|
384
|
+
- `killed`: whether the command exited because it was killed.
|
|
385
|
+
- `exitCode`: the exit code of the command's process, or the signal which it was killed with.
|
|
386
|
+
- `timings`: an object in the shape `{ startDate, endDate, durationSeconds }`.
|
|
387
|
+
|
|
298
388
|
## FAQ
|
|
299
389
|
|
|
300
390
|
* Process exited with code *null*?
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
6
|
+
}) : (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
o[k2] = m[k];
|
|
9
|
+
}));
|
|
10
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
11
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
12
|
+
}) : function(o, v) {
|
|
13
|
+
o["default"] = v;
|
|
14
|
+
});
|
|
15
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
16
|
+
if (mod && mod.__esModule) return mod;
|
|
17
|
+
var result = {};
|
|
18
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
19
|
+
__setModuleDefault(result, mod);
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
27
|
+
const helpers_1 = require("yargs/helpers");
|
|
28
|
+
const defaults = __importStar(require("../src/defaults"));
|
|
29
|
+
const index_1 = __importDefault(require("../src/index"));
|
|
30
|
+
const epilogue_1 = require("./epilogue");
|
|
31
|
+
// Clean-up arguments (yargs expects only the arguments after the program name)
|
|
32
|
+
const cleanArgs = (0, helpers_1.hideBin)(process.argv);
|
|
33
|
+
// Find argument separator (double dash)
|
|
34
|
+
const argsSepIdx = cleanArgs.findIndex((arg) => arg === '--');
|
|
35
|
+
// Arguments before separator
|
|
36
|
+
const argsBeforeSep = argsSepIdx >= 0 ? cleanArgs.slice(0, argsSepIdx) : cleanArgs;
|
|
37
|
+
// Arguments after separator
|
|
38
|
+
const argsAfterSep = argsSepIdx >= 0 ? cleanArgs.slice(argsSepIdx + 1) : [];
|
|
39
|
+
const args = (0, yargs_1.default)(argsBeforeSep)
|
|
40
|
+
.usage('$0 [options] <command ...>')
|
|
41
|
+
.help('h')
|
|
42
|
+
.alias('h', 'help')
|
|
43
|
+
.version()
|
|
44
|
+
.alias('version', 'v')
|
|
45
|
+
.alias('version', 'V')
|
|
46
|
+
// TODO: Add some tests for this.
|
|
47
|
+
.env('CONCURRENTLY')
|
|
48
|
+
.options({
|
|
49
|
+
// General
|
|
50
|
+
'max-processes': {
|
|
51
|
+
alias: 'm',
|
|
52
|
+
describe: 'How many processes should run at once.\n' +
|
|
53
|
+
'New processes only spawn after all restart tries of a process.',
|
|
54
|
+
type: 'number',
|
|
55
|
+
},
|
|
56
|
+
'names': {
|
|
57
|
+
alias: 'n',
|
|
58
|
+
describe: 'List of custom names to be used in prefix template.\n' +
|
|
59
|
+
'Example names: "main,browser,server"',
|
|
60
|
+
type: 'string',
|
|
61
|
+
},
|
|
62
|
+
'name-separator': {
|
|
63
|
+
describe: 'The character to split <names> on. Example usage:\n' +
|
|
64
|
+
'concurrently -n "styles|scripts|server" --name-separator "|"',
|
|
65
|
+
default: defaults.nameSeparator,
|
|
66
|
+
},
|
|
67
|
+
'success': {
|
|
68
|
+
alias: 's',
|
|
69
|
+
describe: 'Which command(s) must exit with code 0 in order for concurrently exit with ' +
|
|
70
|
+
'code 0 too. Options are:\n' +
|
|
71
|
+
'- "first" for the first command to exit;\n' +
|
|
72
|
+
'- "last" for the last command to exit;\n' +
|
|
73
|
+
'- "all" for all commands;\n' +
|
|
74
|
+
// Note: not a typo. Multiple commands can have the same name.
|
|
75
|
+
'- "command-{name}"/"command-{index}" for the commands with that name or index;\n' +
|
|
76
|
+
'- "!command-{name}"/"!command-{index}" for all commands but the ones with that ' +
|
|
77
|
+
'name or index.\n',
|
|
78
|
+
default: defaults.success,
|
|
79
|
+
},
|
|
80
|
+
'raw': {
|
|
81
|
+
alias: 'r',
|
|
82
|
+
describe: 'Output only raw output of processes, disables prettifying ' +
|
|
83
|
+
'and concurrently coloring.',
|
|
84
|
+
type: 'boolean',
|
|
85
|
+
},
|
|
86
|
+
// This one is provided for free. Chalk reads this itself and removes colours.
|
|
87
|
+
// https://www.npmjs.com/package/chalk#chalksupportscolor
|
|
88
|
+
'no-color': {
|
|
89
|
+
describe: 'Disables colors from logging',
|
|
90
|
+
type: 'boolean',
|
|
91
|
+
},
|
|
92
|
+
'hide': {
|
|
93
|
+
describe: 'Comma-separated list of processes to hide the output.\n' +
|
|
94
|
+
'The processes can be identified by their name or index.',
|
|
95
|
+
default: defaults.hide,
|
|
96
|
+
type: 'string',
|
|
97
|
+
},
|
|
98
|
+
'group': {
|
|
99
|
+
alias: 'g',
|
|
100
|
+
describe: 'Order the output as if the commands were run sequentially.',
|
|
101
|
+
type: 'boolean',
|
|
102
|
+
},
|
|
103
|
+
'timings': {
|
|
104
|
+
describe: 'Show timing information for all processes.',
|
|
105
|
+
type: 'boolean',
|
|
106
|
+
default: defaults.timings,
|
|
107
|
+
},
|
|
108
|
+
'passthrough-arguments': {
|
|
109
|
+
alias: 'P',
|
|
110
|
+
describe: 'Passthrough additional arguments to commands (accessible via placeholders) ' +
|
|
111
|
+
'instead of treating them as commands.',
|
|
112
|
+
type: 'boolean',
|
|
113
|
+
default: defaults.passthroughArguments,
|
|
114
|
+
},
|
|
115
|
+
// Kill others
|
|
116
|
+
'kill-others': {
|
|
117
|
+
alias: 'k',
|
|
118
|
+
describe: 'Kill other processes if one exits or dies.',
|
|
119
|
+
type: 'boolean',
|
|
120
|
+
},
|
|
121
|
+
'kill-others-on-fail': {
|
|
122
|
+
describe: 'Kill other processes if one exits with non zero status code.',
|
|
123
|
+
type: 'boolean',
|
|
124
|
+
},
|
|
125
|
+
// Prefix
|
|
126
|
+
'prefix': {
|
|
127
|
+
alias: 'p',
|
|
128
|
+
describe: 'Prefix used in logging for each process.\n' +
|
|
129
|
+
'Possible values: index, pid, time, command, name, none, or a template. ' +
|
|
130
|
+
'Example template: "{time}-{pid}"',
|
|
131
|
+
defaultDescription: 'index or name (when --names is set)',
|
|
132
|
+
type: 'string',
|
|
133
|
+
},
|
|
134
|
+
'prefix-colors': {
|
|
135
|
+
alias: 'c',
|
|
136
|
+
describe: 'Comma-separated list of chalk colors to use on prefixes. ' +
|
|
137
|
+
'If there are more commands than colors, the last color will be repeated.\n' +
|
|
138
|
+
'- Available modifiers: reset, bold, dim, italic, underline, inverse, hidden, strikethrough\n' +
|
|
139
|
+
'- Available colors: black, red, green, yellow, blue, magenta, cyan, white, gray \n' +
|
|
140
|
+
'or any hex values for colors, eg #23de43\n' +
|
|
141
|
+
'- Available background colors: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite\n' +
|
|
142
|
+
'See https://www.npmjs.com/package/chalk for more information.',
|
|
143
|
+
default: defaults.prefixColors,
|
|
144
|
+
type: 'string',
|
|
145
|
+
},
|
|
146
|
+
'prefix-length': {
|
|
147
|
+
alias: 'l',
|
|
148
|
+
describe: 'Limit how many characters of the command is displayed in prefix. ' +
|
|
149
|
+
'The option can be used to shorten the prefix when it is set to "command"',
|
|
150
|
+
default: defaults.prefixLength,
|
|
151
|
+
type: 'number',
|
|
152
|
+
},
|
|
153
|
+
'timestamp-format': {
|
|
154
|
+
alias: 't',
|
|
155
|
+
describe: 'Specify the timestamp in moment/date-fns format.',
|
|
156
|
+
default: defaults.timestampFormat,
|
|
157
|
+
type: 'string',
|
|
158
|
+
},
|
|
159
|
+
// Restarting
|
|
160
|
+
'restart-tries': {
|
|
161
|
+
describe: 'How many times a process that died should restart.\n' +
|
|
162
|
+
'Negative numbers will make the process restart forever.',
|
|
163
|
+
default: defaults.restartTries,
|
|
164
|
+
type: 'number',
|
|
165
|
+
},
|
|
166
|
+
'restart-after': {
|
|
167
|
+
describe: 'Delay time to respawn the process, in milliseconds.',
|
|
168
|
+
default: defaults.restartDelay,
|
|
169
|
+
type: 'number',
|
|
170
|
+
},
|
|
171
|
+
// Input
|
|
172
|
+
'handle-input': {
|
|
173
|
+
alias: 'i',
|
|
174
|
+
describe: 'Whether input should be forwarded to the child processes. ' +
|
|
175
|
+
'See examples for more information.',
|
|
176
|
+
type: 'boolean',
|
|
177
|
+
},
|
|
178
|
+
'default-input-target': {
|
|
179
|
+
default: defaults.defaultInputTarget,
|
|
180
|
+
describe: 'Identifier for child process to which input on stdin ' +
|
|
181
|
+
'should be sent if not specified at start of input.\n' +
|
|
182
|
+
'Can be either the index or the name of the process.',
|
|
183
|
+
},
|
|
184
|
+
})
|
|
185
|
+
.group(['m', 'n', 'name-separator', 's', 'r', 'no-color', 'hide', 'g', 'timings', 'P'], 'General')
|
|
186
|
+
.group(['p', 'c', 'l', 't'], 'Prefix styling')
|
|
187
|
+
.group(['i', 'default-input-target'], 'Input handling')
|
|
188
|
+
.group(['k', 'kill-others-on-fail'], 'Killing other processes')
|
|
189
|
+
.group(['restart-tries', 'restart-after'], 'Restarting')
|
|
190
|
+
.epilogue(epilogue_1.epilogue)
|
|
191
|
+
.parseSync();
|
|
192
|
+
// Get names of commands by the specified separator
|
|
193
|
+
const names = (args.names || '').split(args.nameSeparator);
|
|
194
|
+
// If "passthrough-arguments" is disabled, treat additional arguments as commands
|
|
195
|
+
const commands = args.passthroughArguments ? args._ : [...args._, ...argsAfterSep];
|
|
196
|
+
(0, index_1.default)(commands.map((command, index) => ({
|
|
197
|
+
command: String(command),
|
|
198
|
+
name: names[index],
|
|
199
|
+
})), {
|
|
200
|
+
handleInput: args.handleInput,
|
|
201
|
+
defaultInputTarget: args.defaultInputTarget,
|
|
202
|
+
killOthers: args.killOthers
|
|
203
|
+
? ['success', 'failure']
|
|
204
|
+
: (args.killOthersOnFail ? ['failure'] : []),
|
|
205
|
+
maxProcesses: args.maxProcesses,
|
|
206
|
+
raw: args.raw,
|
|
207
|
+
hide: args.hide.split(','),
|
|
208
|
+
group: args.group,
|
|
209
|
+
prefix: args.prefix,
|
|
210
|
+
prefixColors: args.prefixColors.split(','),
|
|
211
|
+
prefixLength: args.prefixLength,
|
|
212
|
+
restartDelay: args.restartAfter,
|
|
213
|
+
restartTries: args.restartTries,
|
|
214
|
+
successCondition: args.success,
|
|
215
|
+
timestampFormat: args.timestampFormat,
|
|
216
|
+
timings: args.timings,
|
|
217
|
+
additionalArguments: args.passthroughArguments ? argsAfterSep : undefined,
|
|
218
|
+
}).result.then(() => process.exit(0), () => process.exit(1));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const epilogue: string;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.epilogue = void 0;
|
|
4
|
+
// Add new examples here.
|
|
5
|
+
// Always start with `$ $0` so that it a) symbolizes a command line; and b) $0 gets replaced by the binary name uniformly.
|
|
6
|
+
const examples = [
|
|
7
|
+
{
|
|
8
|
+
description: 'Output nothing more than stdout+stderr of child processes',
|
|
9
|
+
example: '$ $0 --raw "npm run watch-less" "npm run watch-js"',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
description: 'Normal output but without colors e.g. when logging to file',
|
|
13
|
+
example: '$ $0 --no-color "grunt watch" "http-server" > log',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
description: 'Custom prefix',
|
|
17
|
+
example: '$ $0 --prefix "{time}-{pid}" "npm run watch" "http-server"',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
description: 'Custom names and colored prefixes',
|
|
21
|
+
example: '$ $0 --names "HTTP,WATCH" -c "bgBlue.bold,bgMagenta.bold" "http-server" "npm run watch"',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
description: 'Configuring via environment variables with CONCURRENTLY_ prefix',
|
|
25
|
+
example: '$ CONCURRENTLY_RAW=true CONCURRENTLY_KILL_OTHERS=true $0 "echo hello" "echo world"',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
description: 'Send input to default',
|
|
29
|
+
example: [
|
|
30
|
+
'$ $0 --handle-input "nodemon" "npm run watch-js"',
|
|
31
|
+
'rs # Sends rs command to nodemon process',
|
|
32
|
+
].join('\n'),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
description: 'Send input to specific child identified by index',
|
|
36
|
+
example: [
|
|
37
|
+
'$ $0 --handle-input "npm run watch-js" nodemon',
|
|
38
|
+
'1:rs',
|
|
39
|
+
].join('\n'),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
description: 'Send input to specific child identified by name',
|
|
43
|
+
example: [
|
|
44
|
+
'$ $0 --handle-input -n js,srv "npm run watch-js" nodemon',
|
|
45
|
+
'srv:rs',
|
|
46
|
+
].join('\n'),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
description: 'Shortened NPM run commands',
|
|
50
|
+
example: '$ $0 npm:watch-node npm:watch-js npm:watch-css',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
description: 'Shortened NPM run command with wildcard (make sure to wrap it in quotes!)',
|
|
54
|
+
example: '$ $0 "npm:watch-*"',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
description: 'Exclude patterns so that between "lint:js" and "lint:fix:js", only "lint:js" is ran',
|
|
58
|
+
example: '$ $0 "npm:*(!fix)"',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
description: 'Passthrough some additional arguments via \'{<number>}\' placeholder',
|
|
62
|
+
example: '$ $0 -P "echo {1}" -- foo',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
description: 'Passthrough all additional arguments via \'{@}\' placeholder',
|
|
66
|
+
example: '$ $0 -P "npm:dev-* -- {@}" -- --watch --noEmit',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
description: 'Passthrough all additional arguments combined via \'{*}\' placeholder',
|
|
70
|
+
example: '$ $0 -P "npm:dev-* -- {*}" -- --watch --noEmit',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
exports.epilogue = `
|
|
74
|
+
Examples:
|
|
75
|
+
${examples.map(({ example, description }) => `
|
|
76
|
+
- ${description}
|
|
77
|
+
|
|
78
|
+
${example.split('\n').map(line => ` ${line}`).join('\n')}
|
|
79
|
+
`).join('')}
|
|
80
|
+
For more details, visit https://github.com/open-cli-tools/concurrently
|
|
81
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CommandInfo } from '../command';
|
|
2
|
+
/**
|
|
3
|
+
* A command parser encapsulates a specific logic for mapping `CommandInfo` objects
|
|
4
|
+
* into another `CommandInfo`.
|
|
5
|
+
*
|
|
6
|
+
* A prime example is turning an abstract `npm:foo` into `npm run foo`, but it could also turn
|
|
7
|
+
* the prefix color of a command brighter, or maybe even prefixing each command with `time(1)`.
|
|
8
|
+
*/
|
|
9
|
+
export interface CommandParser {
|
|
10
|
+
/**
|
|
11
|
+
* Parses `commandInfo` and returns one or more `CommandInfo`s.
|
|
12
|
+
*
|
|
13
|
+
* Returning multiple `CommandInfo` is used when there are multiple possibilities of commands to
|
|
14
|
+
* run given the original input.
|
|
15
|
+
* An example of this is when the command contains a wildcard and it must be expanded into all
|
|
16
|
+
* viable options so that the consumer can decide which ones to run.
|
|
17
|
+
*/
|
|
18
|
+
parse(commandInfo: CommandInfo): CommandInfo | CommandInfo[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CommandInfo } from '../command';
|
|
2
|
+
import { CommandParser } from './command-parser';
|
|
3
|
+
/**
|
|
4
|
+
* Replace placeholders with additional arguments.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ExpandArguments implements CommandParser {
|
|
7
|
+
private readonly additionalArguments;
|
|
8
|
+
constructor(additionalArguments: string[]);
|
|
9
|
+
parse(commandInfo: CommandInfo): CommandInfo & {
|
|
10
|
+
command: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExpandArguments = void 0;
|
|
4
|
+
const shell_quote_1 = require("shell-quote");
|
|
5
|
+
/**
|
|
6
|
+
* Replace placeholders with additional arguments.
|
|
7
|
+
*/
|
|
8
|
+
class ExpandArguments {
|
|
9
|
+
constructor(additionalArguments) {
|
|
10
|
+
this.additionalArguments = additionalArguments;
|
|
11
|
+
}
|
|
12
|
+
parse(commandInfo) {
|
|
13
|
+
const command = commandInfo.command.replace(/\\?\{([@\*]|[1-9][0-9]*)\}/g, (match, placeholderTarget) => {
|
|
14
|
+
// Don't replace the placeholder if it is escaped by a backslash.
|
|
15
|
+
if (match.startsWith('\\')) {
|
|
16
|
+
return match.substring(1);
|
|
17
|
+
}
|
|
18
|
+
// Replace numeric placeholder if value exists in additional arguments.
|
|
19
|
+
if (!isNaN(placeholderTarget) &&
|
|
20
|
+
placeholderTarget <= this.additionalArguments.length) {
|
|
21
|
+
return (0, shell_quote_1.quote)([this.additionalArguments[placeholderTarget - 1]]);
|
|
22
|
+
}
|
|
23
|
+
// Replace all arguments placeholder.
|
|
24
|
+
if (placeholderTarget === '@') {
|
|
25
|
+
return (0, shell_quote_1.quote)(this.additionalArguments);
|
|
26
|
+
}
|
|
27
|
+
// Replace combined arguments placeholder.
|
|
28
|
+
if (placeholderTarget === '*') {
|
|
29
|
+
return (0, shell_quote_1.quote)([this.additionalArguments.join(' ')]);
|
|
30
|
+
}
|
|
31
|
+
// Replace placeholder with empty string
|
|
32
|
+
// if value doesn't exist in additional arguments.
|
|
33
|
+
return '';
|
|
34
|
+
});
|
|
35
|
+
return Object.assign({}, commandInfo, {
|
|
36
|
+
command,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.ExpandArguments = ExpandArguments;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommandInfo } from '../command';
|
|
2
|
+
import { CommandParser } from './command-parser';
|
|
3
|
+
/**
|
|
4
|
+
* Expands commands prefixed with `npm:`, `yarn:` or `pnpm:` into the full version `npm run <command>` and so on.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ExpandNpmShortcut implements CommandParser {
|
|
7
|
+
parse(commandInfo: CommandInfo): CommandInfo;
|
|
8
|
+
}
|