concurrently 6.3.0 → 7.0.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 -35
- package/dist/bin/concurrently.d.ts +2 -0
- package/dist/bin/concurrently.js +193 -0
- package/dist/bin/concurrently.spec.d.ts +1 -0
- package/dist/bin/epilogue.d.ts +1 -0
- package/dist/bin/epilogue.js +65 -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-shortcut.spec.d.ts +1 -0
- package/dist/src/command-parser/expand-npm-wildcard.d.ts +13 -0
- package/dist/src/command-parser/expand-npm-wildcard.js +73 -0
- package/dist/src/command-parser/expand-npm-wildcard.spec.d.ts +1 -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-parser/strip-quotes.spec.d.ts +1 -0
- package/dist/src/command.d.ts +101 -0
- package/dist/src/command.js +101 -0
- package/dist/src/command.spec.d.ts +1 -0
- package/dist/src/completion-listener.d.ts +37 -0
- package/dist/src/completion-listener.js +60 -0
- package/dist/src/completion-listener.spec.d.ts +1 -0
- package/dist/src/concurrently.d.ts +77 -0
- package/dist/src/concurrently.js +120 -0
- package/dist/src/concurrently.spec.d.ts +1 -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/input-handler.spec.d.ts +1 -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-on-signal.spec.d.ts +1 -0
- 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/kill-others.spec.d.ts +1 -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-error.spec.d.ts +1 -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-exit.spec.d.ts +1 -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-output.spec.d.ts +1 -0
- 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/log-timings.spec.d.ts +1 -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/flow-control/restart-process.spec.d.ts +1 -0
- package/dist/src/get-spawn-opts.d.ts +30 -0
- package/dist/src/get-spawn-opts.js +11 -0
- package/dist/src/get-spawn-opts.spec.d.ts +1 -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/dist/src/logger.js +199 -0
- package/dist/src/logger.spec.d.ts +1 -0
- package/dist/src/output-writer.d.ts +19 -0
- package/dist/src/output-writer.js +69 -0
- package/dist/src/output-writer.spec.d.ts +1 -0
- package/index.js +6 -60
- package/index.mjs +9 -0
- package/package.json +37 -11
- package/bin/concurrently.js +0 -170
- package/bin/concurrently.spec.js +0 -365
- package/bin/epilogue.txt +0 -42
- 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 -58
- package/src/command-parser/strip-quotes.spec.js +0 -20
- package/src/command.js +0 -63
- package/src/command.spec.js +0 -183
- package/src/completion-listener.js +0 -39
- package/src/completion-listener.spec.js +0 -88
- package/src/concurrently.js +0 -111
- package/src/concurrently.spec.js +0 -199
- package/src/defaults.js +0 -31
- package/src/flow-control/base-handler.js +0 -16
- 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/restart-process.js +0 -56
- package/src/flow-control/restart-process.spec.js +0 -131
- package/src/get-spawn-opts.js +0 -16
- package/src/get-spawn-opts.spec.js +0 -30
- package/src/logger.js +0 -115
- package/src/logger.spec.js +0 -195
package/README.md
CHANGED
|
@@ -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
|
|
@@ -116,21 +118,29 @@ Help:
|
|
|
116
118
|
concurrently [options] <command ...>
|
|
117
119
|
|
|
118
120
|
General
|
|
119
|
-
-m, --max-processes
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
-n, --names
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
-r, --raw
|
|
128
|
-
|
|
129
|
-
-s, --success
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
-m, --max-processes How many processes should run at once.
|
|
122
|
+
New processes only spawn after all restart tries of a
|
|
123
|
+
process. [number]
|
|
124
|
+
-n, --names List of custom names to be used in prefix template.
|
|
125
|
+
Example names: "main,browser,server" [string]
|
|
126
|
+
--name-separator The character to split <names> on. Example usage:
|
|
127
|
+
concurrently -n "styles|scripts|server" --name-separator
|
|
128
|
+
"|" [default: ","]
|
|
129
|
+
-r, --raw Output only raw output of processes, disables
|
|
130
|
+
prettifying and concurrently coloring. [boolean]
|
|
131
|
+
-s, --success Return exit code of zero or one based on the success or
|
|
132
|
+
failure of the "first" child to terminate, the "last
|
|
133
|
+
child", or succeed only if "all" child processes
|
|
134
|
+
succeed.
|
|
132
135
|
[choices: "first", "last", "all"] [default: "all"]
|
|
133
|
-
|
|
136
|
+
--no-color Disables colors from logging [boolean]
|
|
137
|
+
--hide Comma-separated list of processes to hide the output.
|
|
138
|
+
The processes can be identified by their name or index.
|
|
139
|
+
[string] [default: ""]
|
|
140
|
+
-g, --group Order the output as if the commands were run
|
|
141
|
+
sequentially. [boolean]
|
|
142
|
+
--timings Show timing information for all processes
|
|
143
|
+
[boolean] [default: false]
|
|
134
144
|
|
|
135
145
|
Prefix styling
|
|
136
146
|
-p, --prefix Prefix used in logging for each process.
|
|
@@ -143,12 +153,12 @@ Prefix styling
|
|
|
143
153
|
- Available modifiers: reset, bold, dim, italic,
|
|
144
154
|
underline, inverse, hidden, strikethrough
|
|
145
155
|
- Available colors: black, red, green, yellow, blue,
|
|
146
|
-
magenta, cyan, white, gray
|
|
147
|
-
colors, eg #23de43
|
|
156
|
+
magenta, cyan, white, gray
|
|
157
|
+
or any hex values for colors, eg #23de43
|
|
148
158
|
- Available background colors: bgBlack, bgRed,
|
|
149
159
|
bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite
|
|
150
160
|
See https://www.npmjs.com/package/chalk for more
|
|
151
|
-
information.
|
|
161
|
+
information. [string] [default: "reset"]
|
|
152
162
|
-l, --prefix-length Limit how many characters of the command is displayed
|
|
153
163
|
in prefix. The option can be used to shorten the
|
|
154
164
|
prefix when it is set to "command"
|
|
@@ -157,17 +167,19 @@ Prefix styling
|
|
|
157
167
|
[string] [default: "yyyy-MM-dd HH:mm:ss.SSS"]
|
|
158
168
|
|
|
159
169
|
Input handling
|
|
160
|
-
-i, --handle-input
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
170
|
+
-i, --handle-input Whether input should be forwarded to the child
|
|
171
|
+
processes. See examples for more information.
|
|
172
|
+
[boolean]
|
|
173
|
+
--default-input-target Identifier for child process to which input on
|
|
174
|
+
stdin should be sent if not specified at start of
|
|
175
|
+
input.
|
|
176
|
+
Can be either the index or the name of the
|
|
177
|
+
process. [default: 0]
|
|
166
178
|
|
|
167
179
|
Killing other processes
|
|
168
|
-
-k, --kill-others
|
|
169
|
-
|
|
170
|
-
|
|
180
|
+
-k, --kill-others kill other processes if one exits or dies [boolean]
|
|
181
|
+
--kill-others-on-fail kill other processes if one exits with non zero
|
|
182
|
+
status code [boolean]
|
|
171
183
|
|
|
172
184
|
Restarting
|
|
173
185
|
--restart-tries How many times a process that died should restart.
|
|
@@ -199,6 +211,10 @@ Examples:
|
|
|
199
211
|
$ concurrently --names "HTTP,WATCH" -c "bgBlue.bold,bgMagenta.bold"
|
|
200
212
|
"http-server" "npm run watch"
|
|
201
213
|
|
|
214
|
+
- Configuring via environment variables with CONCURRENTLY_ prefix
|
|
215
|
+
|
|
216
|
+
$ CONCURRENTLY_RAW=true CONCURRENTLY_KILL_OTHERS=true concurrently "echo hello" "echo world"
|
|
217
|
+
|
|
202
218
|
- Send input to default
|
|
203
219
|
|
|
204
220
|
$ concurrently --handle-input "nodemon" "npm run watch-js"
|
|
@@ -218,14 +234,14 @@ Examples:
|
|
|
218
234
|
|
|
219
235
|
$ concurrently npm:watch-node npm:watch-js npm:watch-css
|
|
220
236
|
|
|
221
|
-
- Shortened NPM run command with wildcard
|
|
237
|
+
- Shortened NPM run command with wildcard (make sure to wrap it in quotes!)
|
|
222
238
|
|
|
223
|
-
$ concurrently npm:watch-*
|
|
239
|
+
$ concurrently "npm:watch-*"
|
|
224
240
|
|
|
225
241
|
For more details, visit https://github.com/open-cli-tools/concurrently
|
|
226
242
|
```
|
|
227
243
|
|
|
228
|
-
##
|
|
244
|
+
## API
|
|
229
245
|
concurrently can be used programmatically by using the API documented below:
|
|
230
246
|
|
|
231
247
|
### `concurrently(commands[, options])`
|
|
@@ -264,11 +280,10 @@ concurrently can be used programmatically by using the API documented below:
|
|
|
264
280
|
- `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format)
|
|
265
281
|
to use when prefixing with `time`. Default: `yyyy-MM-dd HH:mm:ss.ZZZ`
|
|
266
282
|
|
|
267
|
-
> Returns
|
|
268
|
-
>
|
|
269
|
-
>
|
|
270
|
-
>
|
|
271
|
-
> `killOthers`. Default values (empty strings or objects) are returned for the fields that were not specified.
|
|
283
|
+
> **Returns:** an object in the shape `{ commands, result }`.
|
|
284
|
+
> - `result`: a `Promise` that resolves if the run was successful (according to `successCondition` option),
|
|
285
|
+
> or rejects, containing an array of [`CloseEvent`](#CloseEvent), in the order that the commands terminated.
|
|
286
|
+
> - `commands`: an array of all spawned [`Command`s](#Command).
|
|
272
287
|
|
|
273
288
|
Example:
|
|
274
289
|
|
|
@@ -287,6 +302,38 @@ concurrently([
|
|
|
287
302
|
}).then(success, failure);
|
|
288
303
|
```
|
|
289
304
|
|
|
305
|
+
### `Command`
|
|
306
|
+
An object that contains all information about a spawned command, and ways to interact with it.
|
|
307
|
+
It has the following properties:
|
|
308
|
+
|
|
309
|
+
- `index`: the index of the command among all commands spawned.
|
|
310
|
+
- `command`: the command line of the command.
|
|
311
|
+
- `name`: the name of the command; defaults to an empty string.
|
|
312
|
+
- `cwd`: the current working directory of the command.
|
|
313
|
+
- `env`: an object with all the environment variables that the command will be spawned with.
|
|
314
|
+
- `killed`: whether the command has been killed.
|
|
315
|
+
- `exited`: whether the command exited yet.
|
|
316
|
+
- `pid`: the command's process ID.
|
|
317
|
+
- `stdin`: a Writable stream to the command's `stdin`.
|
|
318
|
+
- `stdout`: an RxJS observable to the command's `stdout`.
|
|
319
|
+
- `stderr`: an RxJS observable to the command's `stderr`.
|
|
320
|
+
- `error`: an RxJS observable to the command's error events (e.g. when it fails to spawn).
|
|
321
|
+
- `timer`: an RxJS observable to the command's timing events (e.g. starting, stopping).
|
|
322
|
+
- `close`: an RxJS observable to the command's close events.
|
|
323
|
+
See [`CloseEvent`](#CloseEvent) for more information.
|
|
324
|
+
- `start()`: starts the command, setting up all
|
|
325
|
+
- `kill([signal])`: kills the command, optionally specifying a signal (e.g. `SIGTERM`, `SIGKILL`, etc).
|
|
326
|
+
|
|
327
|
+
### `CloseEvent`
|
|
328
|
+
An object with information about a command's closing event.
|
|
329
|
+
It contains the following properties:
|
|
330
|
+
|
|
331
|
+
- `command`: a stripped down version of [`Command`](#command), including only `name`, `command`, `env` and `cwd` properties.
|
|
332
|
+
- `index`: the index of the command among all commands spawned.
|
|
333
|
+
- `killed`: whether the command exited because it was killed.
|
|
334
|
+
- `exitCode`: the exit code of the command's process, or the signal which it was killed with.
|
|
335
|
+
- `timings`: an object in the shape `{ startDate, endDate, durationSeconds }`.
|
|
336
|
+
|
|
290
337
|
## FAQ
|
|
291
338
|
|
|
292
339
|
* 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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const epilogue: string;
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
exports.epilogue = `
|
|
58
|
+
Examples:
|
|
59
|
+
${examples.map(({ example, description }) => `
|
|
60
|
+
- ${description}
|
|
61
|
+
|
|
62
|
+
${example.split('\n').map(line => ` ${line}`).join('\n')}
|
|
63
|
+
`).join('')}
|
|
64
|
+
For more details, visit https://github.com/open-cli-tools/concurrently
|
|
65
|
+
`;
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,73 @@
|
|
|
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
|
+
/**
|
|
26
|
+
* Finds wildcards in npm/yarn/pnpm run commands and replaces them with all matching scripts in the
|
|
27
|
+
* `package.json` file of the current directory.
|
|
28
|
+
*/
|
|
29
|
+
class ExpandNpmWildcard {
|
|
30
|
+
constructor(readPackage = ExpandNpmWildcard.readPackage) {
|
|
31
|
+
this.readPackage = readPackage;
|
|
32
|
+
}
|
|
33
|
+
static readPackage() {
|
|
34
|
+
try {
|
|
35
|
+
const json = fs.readFileSync('package.json', { encoding: 'utf-8' });
|
|
36
|
+
return JSON.parse(json);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
parse(commandInfo) {
|
|
43
|
+
const [, npmCmd, cmdName, args] = commandInfo.command.match(/(npm|yarn|pnpm) run (\S+)([^&]*)/) || [];
|
|
44
|
+
const wildcardPosition = (cmdName || '').indexOf('*');
|
|
45
|
+
// If the regex didn't match an npm script, or it has no wildcard,
|
|
46
|
+
// then we have nothing to do here
|
|
47
|
+
if (!cmdName || wildcardPosition === -1) {
|
|
48
|
+
return commandInfo;
|
|
49
|
+
}
|
|
50
|
+
if (!this.scripts) {
|
|
51
|
+
this.scripts = Object.keys(this.readPackage().scripts || {});
|
|
52
|
+
}
|
|
53
|
+
const preWildcard = _.escapeRegExp(cmdName.substr(0, wildcardPosition));
|
|
54
|
+
const postWildcard = _.escapeRegExp(cmdName.substr(wildcardPosition + 1));
|
|
55
|
+
const wildcardRegex = new RegExp(`^${preWildcard}(.*?)${postWildcard}$`);
|
|
56
|
+
const currentName = commandInfo.name || '';
|
|
57
|
+
return this.scripts
|
|
58
|
+
.map(script => {
|
|
59
|
+
const match = script.match(wildcardRegex);
|
|
60
|
+
if (match) {
|
|
61
|
+
return Object.assign({}, commandInfo, {
|
|
62
|
+
command: `${npmCmd} run ${script}${args}`,
|
|
63
|
+
// Will use an empty command name if command has no name and the wildcard match is empty,
|
|
64
|
+
// e.g. if `npm:watch-*` matches `npm run watch-`.
|
|
65
|
+
name: currentName + match[1],
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
.filter((commandInfo) => !!commandInfo);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.ExpandNpmWildcard = ExpandNpmWildcard;
|
|
73
|
+
;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|