concurrently 3.6.0 → 4.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/.travis.yml +3 -4
- package/.vscode/settings.json +5 -0
- package/CONTRIBUTING.md +1 -4
- package/README.md +131 -94
- package/appveyor.yml +1 -1
- package/bin/concurrently.js +164 -0
- package/bin/concurrently.spec.js +340 -0
- package/bin/epilogue.txt +46 -0
- package/{test/support → bin/fixtures}/read-echo.js +0 -2
- package/index.js +56 -0
- package/package.json +28 -31
- package/src/command-parser/expand-npm-shortcut.js +13 -0
- package/src/command-parser/expand-npm-shortcut.spec.js +36 -0
- package/src/command-parser/expand-npm-wildcard.js +34 -0
- package/src/command-parser/expand-npm-wildcard.spec.js +58 -0
- package/src/command-parser/strip-quotes.js +12 -0
- package/src/command-parser/strip-quotes.spec.js +14 -0
- package/src/command.js +50 -0
- package/src/command.spec.js +142 -0
- package/src/completion-listener.js +35 -0
- package/src/completion-listener.spec.js +88 -0
- package/src/concurrently.js +69 -0
- package/src/concurrently.spec.js +77 -0
- package/src/defaults.js +27 -0
- package/src/flow-control/fixtures/fake-command.js +16 -0
- package/src/flow-control/input-handler.js +39 -0
- package/src/flow-control/input-handler.spec.js +79 -0
- package/src/flow-control/kill-on-signal.js +29 -0
- package/src/flow-control/kill-on-signal.spec.js +70 -0
- package/src/flow-control/kill-others.js +35 -0
- package/src/flow-control/kill-others.spec.js +66 -0
- package/src/flow-control/log-error.js +20 -0
- package/src/flow-control/log-error.spec.js +40 -0
- package/src/flow-control/log-exit.js +13 -0
- package/src/flow-control/log-exit.spec.js +36 -0
- package/src/flow-control/log-output.js +14 -0
- package/src/flow-control/log-output.spec.js +41 -0
- package/src/flow-control/restart-process.js +51 -0
- package/src/flow-control/restart-process.spec.js +129 -0
- package/src/get-spawn-opts.js +12 -0
- package/src/get-spawn-opts.spec.js +18 -0
- package/src/logger.js +109 -0
- package/src/logger.spec.js +178 -0
- package/src/findChild.js +0 -11
- package/src/main.js +0 -563
- package/src/parseCmds.js +0 -65
- package/src/pkgInfo.js +0 -17
- package/test/support/signal.js +0 -13
- package/test/test-findChild.js +0 -39
- package/test/test-functional.js +0 -396
- package/test/test-parseCmds.js +0 -204
- package/test/utils.js +0 -68
package/.travis.yml
CHANGED
package/CONTRIBUTING.md
CHANGED
|
@@ -6,7 +6,6 @@ updated.
|
|
|
6
6
|
|
|
7
7
|
**Pull requests:** You don't need to bump version numbers or modify anything related to releasing. That stuff is fully automated, just write the functionality.
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
# Maintaining
|
|
11
10
|
|
|
12
11
|
## Test
|
|
@@ -14,11 +13,9 @@ updated.
|
|
|
14
13
|
Tests can be run with command:
|
|
15
14
|
|
|
16
15
|
```bash
|
|
17
|
-
|
|
16
|
+
npm run test
|
|
18
17
|
```
|
|
19
18
|
|
|
20
|
-
You need to have *mocha* installed globally with `npm install -g mocha`.
|
|
21
|
-
|
|
22
19
|
## Release
|
|
23
20
|
|
|
24
21
|
* Commit all changes
|
package/README.md
CHANGED
|
@@ -9,6 +9,24 @@ Like `npm run watch-js & npm run watch-less` but better.
|
|
|
9
9
|
|
|
10
10
|

|
|
11
11
|
|
|
12
|
+
**Table of contents**
|
|
13
|
+
- [Why](#why)
|
|
14
|
+
- [Install](#install)
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [Programmatic Usage](#programmatic-usage)
|
|
17
|
+
- [FAQ](#faq)
|
|
18
|
+
|
|
19
|
+
## Why
|
|
20
|
+
|
|
21
|
+
I like [task automation with npm](http://substack.net/task_automation_with_npm_run)
|
|
22
|
+
but the usual way to run multiple commands concurrently is
|
|
23
|
+
`npm run watch-js & npm run watch-css`. That's fine but it's hard to keep
|
|
24
|
+
on track of different outputs. Also if one process fails, others still keep running
|
|
25
|
+
and you won't even notice the difference.
|
|
26
|
+
|
|
27
|
+
Another option would be to just run all commands in separate terminals. I got
|
|
28
|
+
tired of opening terminals and made **concurrently**.
|
|
29
|
+
|
|
12
30
|
**Features:**
|
|
13
31
|
|
|
14
32
|
* Cross platform (including Windows)
|
|
@@ -92,65 +110,70 @@ Help:
|
|
|
92
110
|
|
|
93
111
|
```
|
|
94
112
|
|
|
95
|
-
|
|
113
|
+
concurrently [options] <command ...>
|
|
114
|
+
|
|
115
|
+
General
|
|
116
|
+
-n, --names List of custom names to be used in prefix template.
|
|
117
|
+
Example names: "main,browser,server" [string]
|
|
118
|
+
--name-separator The character to split <names> on. Example usage:
|
|
119
|
+
concurrently -n "styles|scripts|server" --name-separator "|"
|
|
120
|
+
[default: ","]
|
|
121
|
+
-r, --raw Output only raw output of processes, disables prettifying
|
|
122
|
+
and concurrently coloring. [boolean]
|
|
123
|
+
-s, --success Return exit code of zero or one based on the success or
|
|
124
|
+
failure of the "first" child to terminate, the "last child",
|
|
125
|
+
or succeed only if "all" child processes succeed.
|
|
126
|
+
[choices: "first", "last", "all"] [default: "all"]
|
|
127
|
+
--no-color Disables colors from logging [boolean]
|
|
128
|
+
|
|
129
|
+
Prefix styling
|
|
130
|
+
-p, --prefix Prefix used in logging for each process.
|
|
131
|
+
Possible values: index, pid, time, command, name,
|
|
132
|
+
none, or a template. Example template: "{time}-{pid}"
|
|
133
|
+
[string] [default: index or name (when --names is set)]
|
|
134
|
+
-c, --prefix-colors Comma-separated list of chalk colors to use on
|
|
135
|
+
prefixes. If there are more commands than colors, the
|
|
136
|
+
last color will be repeated.
|
|
137
|
+
- Available modifiers: reset, bold, dim, italic,
|
|
138
|
+
underline, inverse, hidden, strikethrough
|
|
139
|
+
- Available colors: black, red, green, yellow, blue,
|
|
140
|
+
magenta, cyan, white, gray
|
|
141
|
+
- Available background colors: bgBlack, bgRed,
|
|
142
|
+
bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite
|
|
143
|
+
See https://www.npmjs.com/package/chalk for more
|
|
144
|
+
information. [string] [default: "gray.dim"]
|
|
145
|
+
-l, --prefix-length Limit how many characters of the command is displayed
|
|
146
|
+
in prefix. The option can be used to shorten the
|
|
147
|
+
prefix when it is set to "command"
|
|
148
|
+
[number] [default: 10]
|
|
149
|
+
-t, --timestamp-format Specify the timestamp in moment/date-fns format.
|
|
150
|
+
[string] [default: "YYYY-MM-DD HH:mm:ss.SSS"]
|
|
151
|
+
|
|
152
|
+
Input handling
|
|
153
|
+
-i, --handle-input Whether input should be forwarded to the child
|
|
154
|
+
processes. See examples for more information.[boolean]
|
|
155
|
+
--default-input-target Identifier for child process to which input on stdin
|
|
156
|
+
should be sent if not specified at start of input.
|
|
157
|
+
Can be either the index or the name of the process.
|
|
158
|
+
[default: 0]
|
|
159
|
+
|
|
160
|
+
Killing other processes
|
|
161
|
+
-k, --kill-others kill other processes if one exits or dies [boolean]
|
|
162
|
+
--kill-others-on-fail kill other processes if one exits with non zero status
|
|
163
|
+
code [boolean]
|
|
164
|
+
|
|
165
|
+
Restarting
|
|
166
|
+
--restart-tries How many times a process that died should restart.
|
|
167
|
+
[number] [default: 0]
|
|
168
|
+
--restart-after Delay time to respawn the process, in milliseconds.
|
|
169
|
+
[number] [default: 0]
|
|
96
170
|
|
|
97
171
|
Options:
|
|
98
|
-
|
|
99
|
-
-
|
|
100
|
-
-V, --version output the version number
|
|
101
|
-
-k, --kill-others kill other processes if one exits or dies
|
|
102
|
-
--kill-others-on-fail kill other processes if one exits with non zero status code
|
|
103
|
-
--no-color disable colors from logging
|
|
104
|
-
-p, --prefix <prefix> prefix used in logging for each process.
|
|
105
|
-
Possible values: index, pid, time, command, name, none, or a template. Default: index or name (when --names is set). Example template: "{time}-{pid}"
|
|
106
|
-
|
|
107
|
-
-n, --names <names> List of custom names to be used in prefix template.
|
|
108
|
-
Example names: "main,browser,server"
|
|
109
|
-
|
|
110
|
-
--name-separator <char> The character to split <names> on.
|
|
111
|
-
Default: ",". Example usage: concurrently -n "styles,scripts|server" --name-separator "|" <command ...>
|
|
112
|
-
|
|
113
|
-
-c, --prefix-colors <colors> Comma-separated list of chalk colors to use on prefixes. If there are more commands than colors, the last color will be repeated.
|
|
114
|
-
Available modifiers: reset, bold, dim, italic, underline, inverse, hidden, strikethrough
|
|
115
|
-
Available colors: black, red, green, yellow, blue, magenta, cyan, white, gray
|
|
116
|
-
Available background colors: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite
|
|
117
|
-
See https://www.npmjs.com/package/chalk for more information.
|
|
118
|
-
Default: "gray.dim". Example: "black.bgWhite,cyan,gray.dim"
|
|
119
|
-
|
|
120
|
-
-t, --timestamp-format <format> specify the timestamp in moment/date-fns format. Default: YYYY-MM-DD HH:mm:ss.SSS
|
|
121
|
-
|
|
122
|
-
-r, --raw output only raw output of processes, disables prettifying and concurrently coloring
|
|
123
|
-
-s, --success <first|last|all> Return exit code of zero or one based on the success or failure of the "first" child to terminate, the "last" child, or succeed only if "all" child processes succeed. Default: all
|
|
124
|
-
|
|
125
|
-
-l, --prefix-length <length> limit how many characters of the command is displayed in prefix.
|
|
126
|
-
The option can be used to shorten long commands.
|
|
127
|
-
Works only if prefix is set to "command". Default: 10
|
|
128
|
-
|
|
129
|
-
--allow-restart Restart a process which died. Default: false
|
|
130
|
-
|
|
131
|
-
--restart-after <miliseconds> delay time to respawn the process. Default: 0
|
|
132
|
-
|
|
133
|
-
--restart-tries <times> limit the number of respawn tries. Default: 1
|
|
134
|
-
|
|
135
|
-
--default-input-target <identifier> identifier for child process to which input on stdin should be sent if not specified at start of input. Can be either the index or the name of the process. Default: 0
|
|
136
|
-
|
|
137
|
-
Input:
|
|
138
|
-
|
|
139
|
-
Input can be sent to any of the child processes using either the name or index
|
|
140
|
-
of the command followed by a colon. If no child identifier is specified then the
|
|
141
|
-
input will be sent to the child specified by the `--default-input-target`
|
|
142
|
-
option, which defaults to index 0.
|
|
172
|
+
-h, --help Show help [boolean]
|
|
173
|
+
-v, -V, --version Show version number [boolean]
|
|
143
174
|
|
|
144
175
|
Examples:
|
|
145
176
|
|
|
146
|
-
- Kill other processes if one exits or dies
|
|
147
|
-
|
|
148
|
-
$ concurrently --kill-others "grunt watch" "http-server"
|
|
149
|
-
|
|
150
|
-
- Kill other processes if one exits with non zero status code
|
|
151
|
-
|
|
152
|
-
$ concurrently --kill-others-on-fail "npm run build:client" "npm run build:server"
|
|
153
|
-
|
|
154
177
|
- Output nothing more than stdout+stderr of child processes
|
|
155
178
|
|
|
156
179
|
$ concurrently --raw "npm run watch-less" "npm run watch-js"
|
|
@@ -165,50 +188,26 @@ Examples:
|
|
|
165
188
|
|
|
166
189
|
- Custom names and colored prefixes
|
|
167
190
|
|
|
168
|
-
$ concurrently --names "HTTP,WATCH" -c "bgBlue.bold,bgMagenta.bold"
|
|
169
|
-
|
|
191
|
+
$ concurrently --names "HTTP,WATCH" -c "bgBlue.bold,bgMagenta.bold"
|
|
192
|
+
"http-server" "npm run watch"
|
|
193
|
+
|
|
170
194
|
- Shortened NPM run commands
|
|
171
195
|
|
|
172
196
|
$ concurrently npm:watch-node npm:watch-js npm:watch-css
|
|
173
197
|
|
|
174
198
|
- Send input to default
|
|
175
199
|
|
|
176
|
-
$ concurrently "nodemon" "npm run watch-js"
|
|
200
|
+
$ concurrently --handle-input "nodemon" "npm run watch-js"
|
|
177
201
|
rs # Sends rs command to nodemon process
|
|
178
202
|
|
|
179
|
-
- Specify a default-input-target
|
|
180
|
-
|
|
181
|
-
$ concurrently --default-input-target 1 "npm run watch-js" nodemon
|
|
182
|
-
rs
|
|
183
|
-
|
|
184
|
-
- Send input to specific child identified by index
|
|
185
|
-
|
|
186
|
-
$ concurrently "npm run watch-js" nodemon
|
|
187
|
-
1:rs
|
|
188
|
-
|
|
189
|
-
- Send input to specific child identified by name
|
|
190
|
-
|
|
191
|
-
$ concurrently -n js,srv "npm run watch-js" nodemon
|
|
192
|
-
srv:rs
|
|
193
|
-
|
|
194
|
-
- Send input to default
|
|
195
|
-
|
|
196
|
-
$ concurrently "nodemon" "npm run watch-js"
|
|
197
|
-
rs # Sends rs command to nodemon process
|
|
198
|
-
|
|
199
|
-
- Specify a default-input-target
|
|
200
|
-
|
|
201
|
-
$ concurrently --default-input-target 1 "npm run watch-js" nodemon
|
|
202
|
-
rs
|
|
203
|
-
|
|
204
203
|
- Send input to specific child identified by index
|
|
205
204
|
|
|
206
|
-
$ concurrently "npm run watch-js" nodemon
|
|
205
|
+
$ concurrently --handle-input "npm run watch-js" nodemon
|
|
207
206
|
1:rs
|
|
208
207
|
|
|
209
208
|
- Send input to specific child identified by name
|
|
210
209
|
|
|
211
|
-
$ concurrently -n js,srv "npm run watch-js" nodemon
|
|
210
|
+
$ concurrently --handle-input -n js,srv "npm run watch-js" nodemon
|
|
212
211
|
srv:rs
|
|
213
212
|
|
|
214
213
|
- Shortened NPM run commands
|
|
@@ -222,6 +221,52 @@ Examples:
|
|
|
222
221
|
For more details, visit https://github.com/kimmobrunfeldt/concurrently
|
|
223
222
|
```
|
|
224
223
|
|
|
224
|
+
## Programmatic Usage
|
|
225
|
+
concurrently can be used programmatically by using the API documented below:
|
|
226
|
+
|
|
227
|
+
### `concurrently(commands[, options])`
|
|
228
|
+
- `commands`: an array of either strings (containing the commands to run) or objects
|
|
229
|
+
with the shape `{ command, name, prefixColor }`.
|
|
230
|
+
- `options` (optional): an object containing any of the below:
|
|
231
|
+
- `defaultInputTarget`: the default input target when reading from `inputStream`.
|
|
232
|
+
Default: `0`.
|
|
233
|
+
- `inputStream`: a [`Readable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_readable_streams)
|
|
234
|
+
to read the input from, eg `process.stdin`.
|
|
235
|
+
- `killOthers`: an array of exitting conditions that will cause a process to kill others.
|
|
236
|
+
Can contain any of `success` or `failure`.
|
|
237
|
+
- `outputStream`: a [`Writable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_writable_streams)
|
|
238
|
+
to write logs to. Default: `process.stdout`.
|
|
239
|
+
- `prefix`: the prefix type to use when logging processes output.
|
|
240
|
+
Possible values: `index`, `pid`, `time`, `command`, `name`, `none`, or a template (eg `[{time} process: {pid}]`).
|
|
241
|
+
Default: the name of the process, or its index if no name is set.
|
|
242
|
+
- `prefixLength`: how many characters to show when prefixing with `command`. Default: `10`
|
|
243
|
+
- `raw`: whether raw mode should be used, meaning strictly process output will
|
|
244
|
+
be logged, without any prefixes, colouring or extra stuff.
|
|
245
|
+
- `successCondition`: the condition to consider the run was successful.
|
|
246
|
+
If `first`, only the first process to exit will make up the success of the run; if `last`, the last process that exits will determine whether the run succeeds.
|
|
247
|
+
Anything else means all processes should exit successfully.
|
|
248
|
+
- `restartTries`: how many attempts to restart a process that dies will be made. Default: `0`.
|
|
249
|
+
- `restartDelay`: how many milliseconds to wait between process restarts. Default: `0`.
|
|
250
|
+
- `timestampFormat`: a [date-fns/moment format](https://date-fns.org/v1.29.0/docs/format)
|
|
251
|
+
to use when prefixing with `time`. Default: `YYYY-MM-DD HH:mm:ss.ZZZ`
|
|
252
|
+
|
|
253
|
+
> Returns: a `Promise` that resolves if the run was successful (according to `successCondition` option),
|
|
254
|
+
> or rejects otherwise.
|
|
255
|
+
|
|
256
|
+
Example:
|
|
257
|
+
|
|
258
|
+
```js
|
|
259
|
+
const concurrently = require('concurrently');
|
|
260
|
+
concurrently([
|
|
261
|
+
'npm:watch-*',
|
|
262
|
+
{ command: 'nodemon', name: 'server' }
|
|
263
|
+
], {
|
|
264
|
+
prefix: 'name',
|
|
265
|
+
killOthers: ['failure', 'success'],
|
|
266
|
+
restartTries: 3,
|
|
267
|
+
}).then(success, failure);
|
|
268
|
+
```
|
|
269
|
+
|
|
225
270
|
## FAQ
|
|
226
271
|
|
|
227
272
|
* Process exited with code *null*?
|
|
@@ -237,14 +282,6 @@ For more details, visit https://github.com/kimmobrunfeldt/concurrently
|
|
|
237
282
|
So *null* means the process didn't terminate normally. This will make **concurrent**
|
|
238
283
|
to return non-zero exit code too.
|
|
239
284
|
|
|
285
|
+
* Does this work with the npm-replacement [yarn](https://github.com/yarnpkg/yarn)?
|
|
240
286
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
I like [task automation with npm](http://substack.net/task_automation_with_npm_run)
|
|
244
|
-
but the usual way to run multiple commands concurrently is
|
|
245
|
-
`npm run watch-js & npm run watch-css`. That's fine but it's hard to keep
|
|
246
|
-
on track of different outputs. Also if one process fails, others still keep running
|
|
247
|
-
and you won't even notice the difference.
|
|
248
|
-
|
|
249
|
-
Another option would be to just run all commands in separate terminals. I got
|
|
250
|
-
tired of opening terminals and made **concurrently**.
|
|
287
|
+
Yes! In all examples above, you may replace "`npm`" with "`yarn`".
|
package/appveyor.yml
CHANGED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const yargs = require('yargs');
|
|
4
|
+
const defaults = require('../src/defaults');
|
|
5
|
+
const concurrently = require('../index');
|
|
6
|
+
|
|
7
|
+
const args = yargs
|
|
8
|
+
.usage('$0 [options] <command ...>')
|
|
9
|
+
.help('h')
|
|
10
|
+
.alias('h', 'help')
|
|
11
|
+
.version('v', require('../package.json').version)
|
|
12
|
+
.alias('v', 'V')
|
|
13
|
+
.alias('v', 'version')
|
|
14
|
+
.options({
|
|
15
|
+
// General
|
|
16
|
+
'n': {
|
|
17
|
+
alias: 'names',
|
|
18
|
+
describe:
|
|
19
|
+
'List of custom names to be used in prefix template.\n' +
|
|
20
|
+
'Example names: "main,browser,server"',
|
|
21
|
+
type: 'string'
|
|
22
|
+
},
|
|
23
|
+
'name-separator': {
|
|
24
|
+
describe:
|
|
25
|
+
'The character to split <names> on. Example usage:\n' +
|
|
26
|
+
'concurrently -n "styles|scripts|server" --name-separator "|"',
|
|
27
|
+
default: defaults.nameSeparator,
|
|
28
|
+
},
|
|
29
|
+
's': {
|
|
30
|
+
alias: 'success',
|
|
31
|
+
describe:
|
|
32
|
+
'Return exit code of zero or one based on the success or failure ' +
|
|
33
|
+
'of the "first" child to terminate, the "last child", or succeed ' +
|
|
34
|
+
'only if "all" child processes succeed.',
|
|
35
|
+
choices: ['first', 'last', 'all'],
|
|
36
|
+
default: defaults.success
|
|
37
|
+
},
|
|
38
|
+
'r': {
|
|
39
|
+
alias: 'raw',
|
|
40
|
+
describe:
|
|
41
|
+
'Output only raw output of processes, disables prettifying ' +
|
|
42
|
+
'and concurrently coloring.',
|
|
43
|
+
type: 'boolean'
|
|
44
|
+
},
|
|
45
|
+
// This one is provided for free. Chalk reads this itself and removes colours.
|
|
46
|
+
// https://www.npmjs.com/package/chalk#chalksupportscolor
|
|
47
|
+
'no-color': {
|
|
48
|
+
describe: 'Disables colors from logging',
|
|
49
|
+
type: 'boolean'
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
// Kill others
|
|
53
|
+
'k': {
|
|
54
|
+
alias: 'kill-others',
|
|
55
|
+
describe: 'kill other processes if one exits or dies',
|
|
56
|
+
type: 'boolean'
|
|
57
|
+
},
|
|
58
|
+
'kill-others-on-fail': {
|
|
59
|
+
describe: 'kill other processes if one exits with non zero status code',
|
|
60
|
+
type: 'boolean'
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// Prefix
|
|
64
|
+
'p': {
|
|
65
|
+
alias: 'prefix',
|
|
66
|
+
describe:
|
|
67
|
+
'Prefix used in logging for each process.\n' +
|
|
68
|
+
'Possible values: index, pid, time, command, name, none, or a template. ' +
|
|
69
|
+
'Example template: "{time}-{pid}"',
|
|
70
|
+
defaultDescription: 'index or name (when --names is set)',
|
|
71
|
+
type: 'string'
|
|
72
|
+
},
|
|
73
|
+
'c': {
|
|
74
|
+
alias: 'prefix-colors',
|
|
75
|
+
describe:
|
|
76
|
+
'Comma-separated list of chalk colors to use on prefixes. ' +
|
|
77
|
+
'If there are more commands than colors, the last color will be repeated.\n' +
|
|
78
|
+
'- Available modifiers: reset, bold, dim, italic, underline, inverse, hidden, strikethrough\n' +
|
|
79
|
+
'- Available colors: black, red, green, yellow, blue, magenta, cyan, white, gray\n' +
|
|
80
|
+
'- Available background colors: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite\n' +
|
|
81
|
+
'See https://www.npmjs.com/package/chalk for more information.',
|
|
82
|
+
default: defaults.prefixColors,
|
|
83
|
+
type: 'string'
|
|
84
|
+
},
|
|
85
|
+
'l': {
|
|
86
|
+
alias: 'prefix-length',
|
|
87
|
+
describe:
|
|
88
|
+
'Limit how many characters of the command is displayed in prefix. ' +
|
|
89
|
+
'The option can be used to shorten the prefix when it is set to "command"',
|
|
90
|
+
default: defaults.prefixLength,
|
|
91
|
+
type: 'number'
|
|
92
|
+
},
|
|
93
|
+
't': {
|
|
94
|
+
alias: 'timestamp-format',
|
|
95
|
+
describe: 'Specify the timestamp in moment/date-fns format.',
|
|
96
|
+
default: defaults.timestampFormat,
|
|
97
|
+
type: 'string'
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
// Restarting
|
|
101
|
+
'restart-tries': {
|
|
102
|
+
describe: 'How many times a process that died should restart.',
|
|
103
|
+
default: defaults.restartTries,
|
|
104
|
+
type: 'number'
|
|
105
|
+
},
|
|
106
|
+
'restart-after': {
|
|
107
|
+
describe: 'Delay time to respawn the process, in milliseconds.',
|
|
108
|
+
default: defaults.restartDelay,
|
|
109
|
+
type: 'number'
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
// Input
|
|
113
|
+
'i': {
|
|
114
|
+
alias: 'handle-input',
|
|
115
|
+
describe:
|
|
116
|
+
'Whether input should be forwarded to the child processes. ' +
|
|
117
|
+
'See examples for more information.',
|
|
118
|
+
type: 'boolean'
|
|
119
|
+
},
|
|
120
|
+
'default-input-target': {
|
|
121
|
+
default: defaults.defaultInputTarget,
|
|
122
|
+
describe:
|
|
123
|
+
'Identifier for child process to which input on stdin ' +
|
|
124
|
+
'should be sent if not specified at start of input.\n' +
|
|
125
|
+
'Can be either the index or the name of the process.'
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
.group(['n', 'name-separator', 'raw', 's', 'no-color'], 'General')
|
|
129
|
+
.group(['p', 'c', 'l', 't'], 'Prefix styling')
|
|
130
|
+
.group(['i', 'default-input-target'], 'Input handling')
|
|
131
|
+
.group(['k', 'kill-others-on-fail'], 'Killing other processes')
|
|
132
|
+
.group(['restart-tries', 'restart-after'], 'Restarting')
|
|
133
|
+
// Too much text to write as JS strings, .txt file is better
|
|
134
|
+
.epilogue(fs.readFileSync(__dirname + '/epilogue.txt', { encoding: 'utf8' }))
|
|
135
|
+
.argv;
|
|
136
|
+
|
|
137
|
+
const prefixColors = args.prefixColors.split(',');
|
|
138
|
+
const names = (args.names || '').split(args.nameSeparator);
|
|
139
|
+
|
|
140
|
+
let lastColor;
|
|
141
|
+
concurrently(args._.map((command, index) => {
|
|
142
|
+
// Use documented behaviour of repeating last colour when specifying more commands than colours
|
|
143
|
+
lastColor = prefixColors[index] || lastColor;
|
|
144
|
+
return {
|
|
145
|
+
command,
|
|
146
|
+
prefixColor: lastColor,
|
|
147
|
+
name: names[index]
|
|
148
|
+
};
|
|
149
|
+
}), {
|
|
150
|
+
inputStream: args.handleInput && process.stdin,
|
|
151
|
+
defaultInputTarget: args.defaultInputTarget,
|
|
152
|
+
killOthers: args.killOthers
|
|
153
|
+
? ['success', 'failure']
|
|
154
|
+
: (args.killOthersOnFail ? ['failure'] : []),
|
|
155
|
+
raw: args.raw,
|
|
156
|
+
prefix: args.prefix,
|
|
157
|
+
restartDelay: args.restartAfter,
|
|
158
|
+
restartTries: args.restartTries,
|
|
159
|
+
successCondition: args.success,
|
|
160
|
+
timestampFormat: args.timestampFormat
|
|
161
|
+
}).then(
|
|
162
|
+
() => process.exit(0),
|
|
163
|
+
() => process.exit(1)
|
|
164
|
+
);
|