concurrently 6.5.0 → 7.1.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 +82 -22
- package/dist/bin/concurrently.d.ts +2 -0
- package/dist/bin/concurrently.js +193 -0
- package/dist/bin/epilogue.d.ts +1 -0
- package/dist/bin/epilogue.js +69 -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-npm-shortcut.d.ts +8 -0
- package/{src → dist/src}/command-parser/expand-npm-shortcut.js +10 -3
- 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/{src → dist/src}/command-parser/strip-quotes.js +10 -4
- package/dist/src/command.d.ts +101 -0
- package/{src → dist/src}/command.js +53 -29
- package/dist/src/completion-listener.d.ts +37 -0
- package/dist/src/completion-listener.js +60 -0
- package/dist/src/concurrently.d.ts +77 -0
- package/dist/src/concurrently.js +120 -0
- package/dist/src/defaults.d.ts +52 -0
- package/dist/src/defaults.js +58 -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 +13 -11
- 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 +69 -0
- package/dist/src/index.js +69 -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 +38 -11
- 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.spec.js +0 -36
- package/src/command-parser/expand-npm-wildcard.js +0 -43
- package/src/command-parser/expand-npm-wildcard.spec.js +0 -87
- 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,6 +109,26 @@ 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:
|
|
@@ -135,6 +157,10 @@ General
|
|
|
135
157
|
--hide Comma-separated list of processes to hide the output.
|
|
136
158
|
The processes can be identified by their name or index.
|
|
137
159
|
[string] [default: ""]
|
|
160
|
+
-g, --group Order the output as if the commands were run
|
|
161
|
+
sequentially. [boolean]
|
|
162
|
+
--timings Show timing information for all processes
|
|
163
|
+
[boolean] [default: false]
|
|
138
164
|
|
|
139
165
|
Prefix styling
|
|
140
166
|
-p, --prefix Prefix used in logging for each process.
|
|
@@ -147,12 +173,12 @@ Prefix styling
|
|
|
147
173
|
- Available modifiers: reset, bold, dim, italic,
|
|
148
174
|
underline, inverse, hidden, strikethrough
|
|
149
175
|
- Available colors: black, red, green, yellow, blue,
|
|
150
|
-
magenta, cyan, white, gray
|
|
151
|
-
colors, eg #23de43
|
|
176
|
+
magenta, cyan, white, gray
|
|
177
|
+
or any hex values for colors, eg #23de43
|
|
152
178
|
- Available background colors: bgBlack, bgRed,
|
|
153
179
|
bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite
|
|
154
180
|
See https://www.npmjs.com/package/chalk for more
|
|
155
|
-
information.
|
|
181
|
+
information. [string] [default: "reset"]
|
|
156
182
|
-l, --prefix-length Limit how many characters of the command is displayed
|
|
157
183
|
in prefix. The option can be used to shorten the
|
|
158
184
|
prefix when it is set to "command"
|
|
@@ -161,17 +187,19 @@ Prefix styling
|
|
|
161
187
|
[string] [default: "yyyy-MM-dd HH:mm:ss.SSS"]
|
|
162
188
|
|
|
163
189
|
Input handling
|
|
164
|
-
-i, --handle-input
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
190
|
+
-i, --handle-input Whether input should be forwarded to the child
|
|
191
|
+
processes. See examples for more information.
|
|
192
|
+
[boolean]
|
|
193
|
+
--default-input-target Identifier for child process to which input on
|
|
194
|
+
stdin should be sent if not specified at start of
|
|
195
|
+
input.
|
|
196
|
+
Can be either the index or the name of the
|
|
197
|
+
process. [default: 0]
|
|
170
198
|
|
|
171
199
|
Killing other processes
|
|
172
|
-
-k, --kill-others
|
|
173
|
-
|
|
174
|
-
|
|
200
|
+
-k, --kill-others kill other processes if one exits or dies [boolean]
|
|
201
|
+
--kill-others-on-fail kill other processes if one exits with non zero
|
|
202
|
+
status code [boolean]
|
|
175
203
|
|
|
176
204
|
Restarting
|
|
177
205
|
--restart-tries How many times a process that died should restart.
|
|
@@ -233,7 +261,7 @@ Examples:
|
|
|
233
261
|
For more details, visit https://github.com/open-cli-tools/concurrently
|
|
234
262
|
```
|
|
235
263
|
|
|
236
|
-
##
|
|
264
|
+
## API
|
|
237
265
|
concurrently can be used programmatically by using the API documented below:
|
|
238
266
|
|
|
239
267
|
### `concurrently(commands[, options])`
|
|
@@ -272,17 +300,16 @@ concurrently can be used programmatically by using the API documented below:
|
|
|
272
300
|
- `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format)
|
|
273
301
|
to use when prefixing with `time`. Default: `yyyy-MM-dd HH:mm:ss.ZZZ`
|
|
274
302
|
|
|
275
|
-
> Returns
|
|
276
|
-
>
|
|
277
|
-
>
|
|
278
|
-
>
|
|
279
|
-
> `killOthers`. Default values (empty strings or objects) are returned for the fields that were not specified.
|
|
303
|
+
> **Returns:** an object in the shape `{ result, commands }`.
|
|
304
|
+
> - `result`: a `Promise` that resolves if the run was successful (according to `successCondition` option),
|
|
305
|
+
> or rejects, containing an array of [`CloseEvent`](#CloseEvent), in the order that the commands terminated.
|
|
306
|
+
> - `commands`: an array of all spawned [`Command`s](#Command).
|
|
280
307
|
|
|
281
308
|
Example:
|
|
282
309
|
|
|
283
310
|
```js
|
|
284
311
|
const concurrently = require('concurrently');
|
|
285
|
-
concurrently([
|
|
312
|
+
const { result } = concurrently([
|
|
286
313
|
'npm:watch-*',
|
|
287
314
|
{ command: 'nodemon', name: 'server' },
|
|
288
315
|
{ command: 'deploy', name: 'deploy', env: { PUBLIC_KEY: '...' } },
|
|
@@ -292,9 +319,42 @@ concurrently([
|
|
|
292
319
|
killOthers: ['failure', 'success'],
|
|
293
320
|
restartTries: 3,
|
|
294
321
|
cwd: path.resolve(__dirname, 'scripts'),
|
|
295
|
-
})
|
|
322
|
+
});
|
|
323
|
+
result.then(success, failure);
|
|
296
324
|
```
|
|
297
325
|
|
|
326
|
+
### `Command`
|
|
327
|
+
An object that contains all information about a spawned command, and ways to interact with it.<br>
|
|
328
|
+
It has the following properties:
|
|
329
|
+
|
|
330
|
+
- `index`: the index of the command among all commands spawned.
|
|
331
|
+
- `command`: the command line of the command.
|
|
332
|
+
- `name`: the name of the command; defaults to an empty string.
|
|
333
|
+
- `cwd`: the current working directory of the command.
|
|
334
|
+
- `env`: an object with all the environment variables that the command will be spawned with.
|
|
335
|
+
- `killed`: whether the command has been killed.
|
|
336
|
+
- `exited`: whether the command exited yet.
|
|
337
|
+
- `pid`: the command's process ID.
|
|
338
|
+
- `stdin`: a Writable stream to the command's `stdin`.
|
|
339
|
+
- `stdout`: an RxJS observable to the command's `stdout`.
|
|
340
|
+
- `stderr`: an RxJS observable to the command's `stderr`.
|
|
341
|
+
- `error`: an RxJS observable to the command's error events (e.g. when it fails to spawn).
|
|
342
|
+
- `timer`: an RxJS observable to the command's timing events (e.g. starting, stopping).
|
|
343
|
+
- `close`: an RxJS observable to the command's close events.
|
|
344
|
+
See [`CloseEvent`](#CloseEvent) for more information.
|
|
345
|
+
- `start()`: starts the command, setting up all
|
|
346
|
+
- `kill([signal])`: kills the command, optionally specifying a signal (e.g. `SIGTERM`, `SIGKILL`, etc).
|
|
347
|
+
|
|
348
|
+
### `CloseEvent`
|
|
349
|
+
An object with information about a command's closing event.<br>
|
|
350
|
+
It contains the following properties:
|
|
351
|
+
|
|
352
|
+
- `command`: a stripped down version of [`Command`](#command), including only `name`, `command`, `env` and `cwd` properties.
|
|
353
|
+
- `index`: the index of the command among all commands spawned.
|
|
354
|
+
- `killed`: whether the command exited because it was killed.
|
|
355
|
+
- `exitCode`: the exit code of the command's process, or the signal which it was killed with.
|
|
356
|
+
- `timings`: an object in the shape `{ startDate, endDate, durationSeconds }`.
|
|
357
|
+
|
|
298
358
|
## FAQ
|
|
299
359
|
|
|
300
360
|
* Process exited with code *null*?
|
|
@@ -0,0 +1,193 @@
|
|
|
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 defaults = __importStar(require("../src/defaults"));
|
|
28
|
+
const index_1 = __importDefault(require("../src/index"));
|
|
29
|
+
const epilogue_1 = require("./epilogue");
|
|
30
|
+
const args = yargs_1.default
|
|
31
|
+
.usage('$0 [options] <command ...>')
|
|
32
|
+
.help('h')
|
|
33
|
+
.alias('h', 'help')
|
|
34
|
+
.version()
|
|
35
|
+
.alias('version', 'v')
|
|
36
|
+
.alias('version', 'V')
|
|
37
|
+
// TODO: Add some tests for this.
|
|
38
|
+
.env('CONCURRENTLY')
|
|
39
|
+
.options({
|
|
40
|
+
// General
|
|
41
|
+
'max-processes': {
|
|
42
|
+
alias: 'm',
|
|
43
|
+
describe: 'How many processes should run at once.\n' +
|
|
44
|
+
'New processes only spawn after all restart tries of a process.',
|
|
45
|
+
type: 'number'
|
|
46
|
+
},
|
|
47
|
+
'names': {
|
|
48
|
+
alias: 'n',
|
|
49
|
+
describe: 'List of custom names to be used in prefix template.\n' +
|
|
50
|
+
'Example names: "main,browser,server"',
|
|
51
|
+
type: 'string'
|
|
52
|
+
},
|
|
53
|
+
'name-separator': {
|
|
54
|
+
describe: 'The character to split <names> on. Example usage:\n' +
|
|
55
|
+
'concurrently -n "styles|scripts|server" --name-separator "|"',
|
|
56
|
+
default: defaults.nameSeparator,
|
|
57
|
+
},
|
|
58
|
+
'success': {
|
|
59
|
+
alias: 's',
|
|
60
|
+
describe: 'Return exit code of zero or one based on the success or failure ' +
|
|
61
|
+
'of the "first" child to terminate, the "last child", or succeed ' +
|
|
62
|
+
'only if "all" child processes succeed.',
|
|
63
|
+
choices: ['first', 'last', 'all'],
|
|
64
|
+
default: defaults.success
|
|
65
|
+
},
|
|
66
|
+
'raw': {
|
|
67
|
+
alias: 'r',
|
|
68
|
+
describe: 'Output only raw output of processes, disables prettifying ' +
|
|
69
|
+
'and concurrently coloring.',
|
|
70
|
+
type: 'boolean'
|
|
71
|
+
},
|
|
72
|
+
// This one is provided for free. Chalk reads this itself and removes colours.
|
|
73
|
+
// https://www.npmjs.com/package/chalk#chalksupportscolor
|
|
74
|
+
'no-color': {
|
|
75
|
+
describe: 'Disables colors from logging',
|
|
76
|
+
type: 'boolean'
|
|
77
|
+
},
|
|
78
|
+
'hide': {
|
|
79
|
+
describe: 'Comma-separated list of processes to hide the output.\n' +
|
|
80
|
+
'The processes can be identified by their name or index.',
|
|
81
|
+
default: defaults.hide,
|
|
82
|
+
type: 'string'
|
|
83
|
+
},
|
|
84
|
+
'group': {
|
|
85
|
+
alias: 'g',
|
|
86
|
+
describe: 'Order the output as if the commands were run sequentially.',
|
|
87
|
+
type: 'boolean'
|
|
88
|
+
},
|
|
89
|
+
'timings': {
|
|
90
|
+
describe: 'Show timing information for all processes',
|
|
91
|
+
type: 'boolean',
|
|
92
|
+
default: defaults.timings
|
|
93
|
+
},
|
|
94
|
+
// Kill others
|
|
95
|
+
'kill-others': {
|
|
96
|
+
alias: 'k',
|
|
97
|
+
describe: 'kill other processes if one exits or dies',
|
|
98
|
+
type: 'boolean'
|
|
99
|
+
},
|
|
100
|
+
'kill-others-on-fail': {
|
|
101
|
+
describe: 'kill other processes if one exits with non zero status code',
|
|
102
|
+
type: 'boolean'
|
|
103
|
+
},
|
|
104
|
+
// Prefix
|
|
105
|
+
'prefix': {
|
|
106
|
+
alias: 'p',
|
|
107
|
+
describe: 'Prefix used in logging for each process.\n' +
|
|
108
|
+
'Possible values: index, pid, time, command, name, none, or a template. ' +
|
|
109
|
+
'Example template: "{time}-{pid}"',
|
|
110
|
+
defaultDescription: 'index or name (when --names is set)',
|
|
111
|
+
type: 'string'
|
|
112
|
+
},
|
|
113
|
+
'prefix-colors': {
|
|
114
|
+
alias: 'c',
|
|
115
|
+
describe: 'Comma-separated list of chalk colors to use on prefixes. ' +
|
|
116
|
+
'If there are more commands than colors, the last color will be repeated.\n' +
|
|
117
|
+
'- Available modifiers: reset, bold, dim, italic, underline, inverse, hidden, strikethrough\n' +
|
|
118
|
+
'- Available colors: black, red, green, yellow, blue, magenta, cyan, white, gray \n' +
|
|
119
|
+
'or any hex values for colors, eg #23de43\n' +
|
|
120
|
+
'- Available background colors: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite\n' +
|
|
121
|
+
'See https://www.npmjs.com/package/chalk for more information.',
|
|
122
|
+
default: defaults.prefixColors,
|
|
123
|
+
type: 'string'
|
|
124
|
+
},
|
|
125
|
+
'prefix-length': {
|
|
126
|
+
alias: 'l',
|
|
127
|
+
describe: 'Limit how many characters of the command is displayed in prefix. ' +
|
|
128
|
+
'The option can be used to shorten the prefix when it is set to "command"',
|
|
129
|
+
default: defaults.prefixLength,
|
|
130
|
+
type: 'number'
|
|
131
|
+
},
|
|
132
|
+
'timestamp-format': {
|
|
133
|
+
alias: 't',
|
|
134
|
+
describe: 'Specify the timestamp in moment/date-fns format.',
|
|
135
|
+
default: defaults.timestampFormat,
|
|
136
|
+
type: 'string'
|
|
137
|
+
},
|
|
138
|
+
// Restarting
|
|
139
|
+
'restart-tries': {
|
|
140
|
+
describe: 'How many times a process that died should restart.\n' +
|
|
141
|
+
'Negative numbers will make the process restart forever.',
|
|
142
|
+
default: defaults.restartTries,
|
|
143
|
+
type: 'number'
|
|
144
|
+
},
|
|
145
|
+
'restart-after': {
|
|
146
|
+
describe: 'Delay time to respawn the process, in milliseconds.',
|
|
147
|
+
default: defaults.restartDelay,
|
|
148
|
+
type: 'number'
|
|
149
|
+
},
|
|
150
|
+
// Input
|
|
151
|
+
'handle-input': {
|
|
152
|
+
alias: 'i',
|
|
153
|
+
describe: 'Whether input should be forwarded to the child processes. ' +
|
|
154
|
+
'See examples for more information.',
|
|
155
|
+
type: 'boolean'
|
|
156
|
+
},
|
|
157
|
+
'default-input-target': {
|
|
158
|
+
default: defaults.defaultInputTarget,
|
|
159
|
+
describe: 'Identifier for child process to which input on stdin ' +
|
|
160
|
+
'should be sent if not specified at start of input.\n' +
|
|
161
|
+
'Can be either the index or the name of the process.'
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
.group(['m', 'n', 'name-separator', 'raw', 's', 'no-color', 'hide', 'group', 'timings'], 'General')
|
|
165
|
+
.group(['p', 'c', 'l', 't'], 'Prefix styling')
|
|
166
|
+
.group(['i', 'default-input-target'], 'Input handling')
|
|
167
|
+
.group(['k', 'kill-others-on-fail'], 'Killing other processes')
|
|
168
|
+
.group(['restart-tries', 'restart-after'], 'Restarting')
|
|
169
|
+
.epilogue(epilogue_1.epilogue)
|
|
170
|
+
.argv;
|
|
171
|
+
const names = (args.names || '').split(args['name-separator']);
|
|
172
|
+
(0, index_1.default)(args._.map((command, index) => ({
|
|
173
|
+
command: String(command),
|
|
174
|
+
name: names[index]
|
|
175
|
+
})), {
|
|
176
|
+
handleInput: args['handle-input'],
|
|
177
|
+
defaultInputTarget: args['default-input-target'],
|
|
178
|
+
killOthers: args.killOthers
|
|
179
|
+
? ['success', 'failure']
|
|
180
|
+
: (args.killOthersOnFail ? ['failure'] : []),
|
|
181
|
+
maxProcesses: args['max-processes'],
|
|
182
|
+
raw: args.raw,
|
|
183
|
+
hide: args.hide.split(','),
|
|
184
|
+
group: args.group,
|
|
185
|
+
prefix: args.prefix,
|
|
186
|
+
prefixColors: args['prefix-colors'].split(','),
|
|
187
|
+
prefixLength: args['prefix-length'],
|
|
188
|
+
restartDelay: args['restart-after'],
|
|
189
|
+
restartTries: args['restart-tries'],
|
|
190
|
+
successCondition: args.success,
|
|
191
|
+
timestampFormat: args['timestamp-format'],
|
|
192
|
+
timings: args.timings
|
|
193
|
+
}).result.then(() => process.exit(0), () => process.exit(1));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const epilogue: string;
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
exports.epilogue = `
|
|
62
|
+
Examples:
|
|
63
|
+
${examples.map(({ example, description }) => `
|
|
64
|
+
- ${description}
|
|
65
|
+
|
|
66
|
+
${example.split('\n').map(line => ` ${line}`).join('\n')}
|
|
67
|
+
`).join('')}
|
|
68
|
+
For more details, visit https://github.com/open-cli-tools/concurrently
|
|
69
|
+
`;
|
|
@@ -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,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
|
+
}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExpandNpmShortcut = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Expands commands prefixed with `npm:`, `yarn:` or `pnpm:` into the full version `npm run <command>` and so on.
|
|
6
|
+
*/
|
|
7
|
+
class ExpandNpmShortcut {
|
|
2
8
|
parse(commandInfo) {
|
|
3
9
|
const [, npmCmd, cmdName, args] = commandInfo.command.match(/^(npm|yarn|pnpm):(\S+)(.*)/) || [];
|
|
4
10
|
if (!cmdName) {
|
|
5
11
|
return commandInfo;
|
|
6
12
|
}
|
|
7
|
-
|
|
8
13
|
return Object.assign({}, commandInfo, {
|
|
9
14
|
name: commandInfo.name || cmdName,
|
|
10
15
|
command: `${npmCmd} run ${cmdName}${args}`
|
|
11
16
|
});
|
|
12
17
|
}
|
|
13
|
-
}
|
|
18
|
+
}
|
|
19
|
+
exports.ExpandNpmShortcut = ExpandNpmShortcut;
|
|
20
|
+
;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommandInfo } from '../command';
|
|
2
|
+
import { CommandParser } from './command-parser';
|
|
3
|
+
/**
|
|
4
|
+
* Finds wildcards in npm/yarn/pnpm run commands and replaces them with all matching scripts in the
|
|
5
|
+
* `package.json` file of the current directory.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ExpandNpmWildcard implements CommandParser {
|
|
8
|
+
private readonly readPackage;
|
|
9
|
+
static readPackage(): any;
|
|
10
|
+
private scripts?;
|
|
11
|
+
constructor(readPackage?: typeof ExpandNpmWildcard.readPackage);
|
|
12
|
+
parse(commandInfo: CommandInfo): CommandInfo | CommandInfo[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.ExpandNpmWildcard = void 0;
|
|
23
|
+
const fs = __importStar(require("fs"));
|
|
24
|
+
const _ = __importStar(require("lodash"));
|
|
25
|
+
const OMISSION = /\(!([^\)]+)\)/;
|
|
26
|
+
/**
|
|
27
|
+
* Finds wildcards in npm/yarn/pnpm run commands and replaces them with all matching scripts in the
|
|
28
|
+
* `package.json` file of the current directory.
|
|
29
|
+
*/
|
|
30
|
+
class ExpandNpmWildcard {
|
|
31
|
+
constructor(readPackage = ExpandNpmWildcard.readPackage) {
|
|
32
|
+
this.readPackage = readPackage;
|
|
33
|
+
}
|
|
34
|
+
static readPackage() {
|
|
35
|
+
try {
|
|
36
|
+
const json = fs.readFileSync('package.json', { encoding: 'utf-8' });
|
|
37
|
+
return JSON.parse(json);
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
parse(commandInfo) {
|
|
44
|
+
const [, npmCmd, cmdName, args] = commandInfo.command.match(/(npm|yarn|pnpm) run (\S+)([^&]*)/) || [];
|
|
45
|
+
const wildcardPosition = (cmdName || '').indexOf('*');
|
|
46
|
+
// If the regex didn't match an npm script, or it has no wildcard,
|
|
47
|
+
// then we have nothing to do here
|
|
48
|
+
if (!cmdName || wildcardPosition === -1) {
|
|
49
|
+
return commandInfo;
|
|
50
|
+
}
|
|
51
|
+
if (!this.scripts) {
|
|
52
|
+
this.scripts = Object.keys(this.readPackage().scripts || {});
|
|
53
|
+
}
|
|
54
|
+
const omissionRegex = cmdName.match(OMISSION);
|
|
55
|
+
const cmdNameSansOmission = cmdName.replace(OMISSION, '');
|
|
56
|
+
const preWildcard = _.escapeRegExp(cmdNameSansOmission.substr(0, wildcardPosition));
|
|
57
|
+
const postWildcard = _.escapeRegExp(cmdNameSansOmission.substr(wildcardPosition + 1));
|
|
58
|
+
const wildcardRegex = new RegExp(`^${preWildcard}(.*?)${postWildcard}$`);
|
|
59
|
+
const currentName = commandInfo.name || '';
|
|
60
|
+
return this.scripts
|
|
61
|
+
.map(script => {
|
|
62
|
+
const match = script.match(wildcardRegex);
|
|
63
|
+
if (omissionRegex) {
|
|
64
|
+
const toOmit = script.match(new RegExp(omissionRegex[1]));
|
|
65
|
+
if (toOmit) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (match) {
|
|
70
|
+
return Object.assign({}, commandInfo, {
|
|
71
|
+
command: `${npmCmd} run ${script}${args}`,
|
|
72
|
+
// Will use an empty command name if command has no name and the wildcard match is empty,
|
|
73
|
+
// e.g. if `npm:watch-*` matches `npm run watch-`.
|
|
74
|
+
name: currentName + match[1],
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
.filter((commandInfo) => !!commandInfo);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.ExpandNpmWildcard = ExpandNpmWildcard;
|
|
82
|
+
;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommandInfo } from '../command';
|
|
2
|
+
import { CommandParser } from './command-parser';
|
|
3
|
+
/**
|
|
4
|
+
* Strips quotes around commands so that they can run on the current shell.
|
|
5
|
+
*/
|
|
6
|
+
export declare class StripQuotes implements CommandParser {
|
|
7
|
+
parse(commandInfo: CommandInfo): CommandInfo & {
|
|
8
|
+
command: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StripQuotes = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Strips quotes around commands so that they can run on the current shell.
|
|
6
|
+
*/
|
|
7
|
+
class StripQuotes {
|
|
2
8
|
parse(commandInfo) {
|
|
3
9
|
let { command } = commandInfo;
|
|
4
|
-
|
|
5
10
|
// Removes the quotes surrounding a command.
|
|
6
11
|
if (/^"(.+?)"$/.test(command) || /^'(.+?)'$/.test(command)) {
|
|
7
12
|
command = command.substr(1, command.length - 2);
|
|
8
13
|
}
|
|
9
|
-
|
|
10
14
|
return Object.assign({}, commandInfo, { command });
|
|
11
15
|
}
|
|
12
|
-
}
|
|
16
|
+
}
|
|
17
|
+
exports.StripQuotes = StripQuotes;
|
|
18
|
+
;
|