concurrently 7.2.0 → 7.3.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 -67
- package/dist/bin/concurrently.js +16 -10
- package/dist/bin/epilogue.js +16 -15
- package/dist/src/command-parser/expand-arguments.d.ts +5 -1
- package/dist/src/command-parser/expand-arguments.js +3 -5
- package/dist/src/command-parser/expand-npm-shortcut.js +3 -3
- package/dist/src/command-parser/expand-npm-wildcard.js +11 -27
- package/dist/src/command-parser/strip-quotes.d.ts +5 -1
- package/dist/src/command-parser/strip-quotes.js +2 -3
- package/dist/src/command.d.ts +5 -2
- package/dist/src/command.js +6 -3
- package/dist/src/completion-listener.d.ts +2 -2
- package/dist/src/completion-listener.js +16 -16
- package/dist/src/concurrently.js +13 -10
- package/dist/src/flow-control/input-handler.d.ts +1 -1
- package/dist/src/flow-control/input-handler.js +8 -5
- package/dist/src/flow-control/kill-on-signal.js +1 -2
- package/dist/src/flow-control/kill-others.d.ts +1 -1
- package/dist/src/flow-control/kill-others.js +2 -4
- package/dist/src/flow-control/log-error.js +1 -2
- package/dist/src/flow-control/log-exit.js +0 -1
- package/dist/src/flow-control/log-output.js +0 -1
- package/dist/src/flow-control/log-timings.d.ts +3 -3
- package/dist/src/flow-control/log-timings.js +12 -12
- package/dist/src/flow-control/restart-process.d.ts +1 -1
- package/dist/src/flow-control/restart-process.js +9 -4
- package/dist/src/get-spawn-opts.d.ts +4 -1
- package/dist/src/get-spawn-opts.js +9 -2
- package/dist/src/logger.d.ts +2 -2
- package/dist/src/logger.js +13 -10
- package/dist/src/output-writer.d.ts +1 -1
- package/dist/src/output-writer.js +7 -5
- package/index.js +1 -0
- package/package.json +30 -27
package/README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# concurrently
|
|
2
2
|
|
|
3
|
-
[](https://github.com/open-cli-tools/concurrently/releases)
|
|
4
|
+
[](https://github.com/open-cli-tools/concurrently/blob/main/LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/concurrently)
|
|
6
|
+
[](https://github.com/open-cli-tools/concurrently/actions/workflows/ci.yml)
|
|
7
|
+
[](https://coveralls.io/github/open-cli-tools/concurrently?branch=main)
|
|
7
8
|
|
|
8
9
|
Run multiple commands concurrently.
|
|
9
10
|
Like `npm run watch-js & npm run watch-less` but better.
|
|
10
11
|
|
|
11
|
-

|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
**Table of Contents**
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
- [Concurrently](#concurrently)
|
|
16
|
+
- [concurrently](#concurrently)
|
|
15
17
|
- [Why](#why)
|
|
16
18
|
- [Install](#install)
|
|
17
19
|
- [Usage](#usage)
|
|
@@ -34,10 +36,10 @@ tired of opening terminals and made **concurrently**.
|
|
|
34
36
|
|
|
35
37
|
**Features:**
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
- Cross platform (including Windows)
|
|
40
|
+
- Output is easy to follow with prefixes
|
|
41
|
+
- With `--kill-others` switch, all commands are killed if one dies
|
|
42
|
+
- Spawns commands with [spawn-command](https://github.com/mmalecki/spawn-command)
|
|
41
43
|
|
|
42
44
|
## Install
|
|
43
45
|
|
|
@@ -56,6 +58,7 @@ npm install concurrently --save
|
|
|
56
58
|
## Usage
|
|
57
59
|
|
|
58
60
|
Remember to surround separate commands with quotes:
|
|
61
|
+
|
|
59
62
|
```bash
|
|
60
63
|
concurrently "command1 arg" "command2 arg"
|
|
61
64
|
```
|
|
@@ -81,17 +84,17 @@ concurrently -n watch-js,watch-css,watch-node "npm run watch-js" "npm run watch-
|
|
|
81
84
|
NPM shortened commands also support wildcards. Given the following scripts in
|
|
82
85
|
package.json:
|
|
83
86
|
|
|
84
|
-
```
|
|
87
|
+
```jsonc
|
|
85
88
|
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// ...
|
|
89
|
-
"watch-js": "...",
|
|
90
|
-
"watch-css": "...",
|
|
91
|
-
"watch-node": "...",
|
|
92
|
-
// ...
|
|
93
|
-
},
|
|
89
|
+
//...
|
|
90
|
+
"scripts": {
|
|
94
91
|
// ...
|
|
92
|
+
"watch-js": "...",
|
|
93
|
+
"watch-css": "...",
|
|
94
|
+
"watch-node": "..."
|
|
95
|
+
// ...
|
|
96
|
+
}
|
|
97
|
+
// ...
|
|
95
98
|
}
|
|
96
99
|
```
|
|
97
100
|
|
|
@@ -110,19 +113,21 @@ concurrently -n w:js,w:css,w:node "npm run watch-js" "npm run watch-css" "npm ru
|
|
|
110
113
|
```
|
|
111
114
|
|
|
112
115
|
Exclusion is also supported. Given the following scripts in package.json:
|
|
113
|
-
|
|
116
|
+
|
|
117
|
+
```jsonc
|
|
114
118
|
{
|
|
119
|
+
// ...
|
|
120
|
+
"scripts": {
|
|
121
|
+
"lint:js": "...",
|
|
122
|
+
"lint:ts": "...",
|
|
123
|
+
"lint:fix:js": "...",
|
|
124
|
+
"lint:fix:ts": "..."
|
|
115
125
|
// ...
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"lint:ts": "...",
|
|
119
|
-
"lint:fix:js": "...",
|
|
120
|
-
"lint:fix:ts": "...",
|
|
121
|
-
// ...
|
|
122
|
-
}
|
|
123
|
-
// ...
|
|
126
|
+
}
|
|
127
|
+
// ...
|
|
124
128
|
}
|
|
125
129
|
```
|
|
130
|
+
|
|
126
131
|
```bash
|
|
127
132
|
# Running only lint:js and lint:ts
|
|
128
133
|
# with lint:fix:js and lint:fix:ts excluded
|
|
@@ -291,7 +296,8 @@ For more details, visit https://github.com/open-cli-tools/concurrently
|
|
|
291
296
|
```
|
|
292
297
|
|
|
293
298
|
## API
|
|
294
|
-
|
|
299
|
+
|
|
300
|
+
**concurrently** can be used programmatically by using the API documented below:
|
|
295
301
|
|
|
296
302
|
### `concurrently(commands[, options])`
|
|
297
303
|
|
|
@@ -299,38 +305,39 @@ concurrently can be used programmatically by using the API documented below:
|
|
|
299
305
|
with the shape `{ command, name, prefixColor, env, cwd }`.
|
|
300
306
|
|
|
301
307
|
- `options` (optional): an object containing any of the below:
|
|
302
|
-
|
|
308
|
+
- `cwd`: the working directory to be used by all commands. Can be overriden per command.
|
|
303
309
|
Default: `process.cwd()`.
|
|
304
|
-
|
|
310
|
+
- `defaultInputTarget`: the default input target when reading from `inputStream`.
|
|
305
311
|
Default: `0`.
|
|
306
|
-
|
|
307
|
-
|
|
312
|
+
- `handleInput`: when `true`, reads input from `process.stdin`.
|
|
313
|
+
- `inputStream`: a [`Readable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_readable_streams)
|
|
308
314
|
to read the input from. Should only be used in the rare instance you would like to stream anything other than `process.stdin`. Overrides `handleInput`.
|
|
309
|
-
|
|
310
|
-
|
|
315
|
+
- `pauseInputStreamOnFinish`: by default, pauses the input stream (`process.stdin` when `handleInput` is enabled, or `inputStream` if provided) when all of the processes have finished. If you need to read from the input stream after `concurrently` has finished, set this to `false`. ([#252](https://github.com/kimmobrunfeldt/concurrently/issues/252)).
|
|
316
|
+
- `killOthers`: an array of exitting conditions that will cause a process to kill others.
|
|
311
317
|
Can contain any of `success` or `failure`.
|
|
312
|
-
|
|
313
|
-
|
|
318
|
+
- `maxProcesses`: how many processes should run at once.
|
|
319
|
+
- `outputStream`: a [`Writable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_writable_streams)
|
|
314
320
|
to write logs to. Default: `process.stdout`.
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
- `prefix`: the prefix type to use when logging processes output.
|
|
322
|
+
Possible values: `index`, `pid`, `time`, `command`, `name`, `none`, or a template (eg `[{time} process: {pid}]`).
|
|
323
|
+
Default: the name of the process, or its index if no name is set.
|
|
324
|
+
- `prefixColors`: a list of colors as supported by [chalk](https://www.npmjs.com/package/chalk).
|
|
325
|
+
If concurrently would run more commands than there are colors, the last color is repeated.
|
|
326
|
+
Prefix colors specified per-command take precedence over this list.
|
|
327
|
+
- `prefixLength`: how many characters to show when prefixing with `command`. Default: `10`
|
|
328
|
+
- `raw`: whether raw mode should be used, meaning strictly process output will
|
|
323
329
|
be logged, without any prefixes, colouring or extra stuff.
|
|
324
|
-
|
|
330
|
+
- `successCondition`: the condition to consider the run was successful.
|
|
325
331
|
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.
|
|
326
332
|
Anything else means all processes should exit successfully.
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
333
|
+
- `restartTries`: how many attempts to restart a process that dies will be made. Default: `0`.
|
|
334
|
+
- `restartDelay`: how many milliseconds to wait between process restarts. Default: `0`.
|
|
335
|
+
- `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format)
|
|
330
336
|
to use when prefixing with `time`. Default: `yyyy-MM-dd HH:mm:ss.ZZZ`
|
|
331
|
-
|
|
337
|
+
- `additionalArguments`: list of additional arguments passed that will get replaced in each command. If not defined, no argument replacing will happen.
|
|
332
338
|
|
|
333
339
|
> **Returns:** an object in the shape `{ result, commands }`.
|
|
340
|
+
>
|
|
334
341
|
> - `result`: a `Promise` that resolves if the run was successful (according to `successCondition` option),
|
|
335
342
|
> or rejects, containing an array of [`CloseEvent`](#CloseEvent), in the order that the commands terminated.
|
|
336
343
|
> - `commands`: an array of all spawned [`Command`s](#Command).
|
|
@@ -339,21 +346,29 @@ Example:
|
|
|
339
346
|
|
|
340
347
|
```js
|
|
341
348
|
const concurrently = require('concurrently');
|
|
342
|
-
const { result } = concurrently(
|
|
349
|
+
const { result } = concurrently(
|
|
350
|
+
[
|
|
343
351
|
'npm:watch-*',
|
|
344
352
|
{ command: 'nodemon', name: 'server' },
|
|
345
353
|
{ command: 'deploy', name: 'deploy', env: { PUBLIC_KEY: '...' } },
|
|
346
|
-
{
|
|
347
|
-
|
|
354
|
+
{
|
|
355
|
+
command: 'watch',
|
|
356
|
+
name: 'watch',
|
|
357
|
+
cwd: path.resolve(__dirname, 'scripts/watchers'),
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
{
|
|
348
361
|
prefix: 'name',
|
|
349
362
|
killOthers: ['failure', 'success'],
|
|
350
363
|
restartTries: 3,
|
|
351
364
|
cwd: path.resolve(__dirname, 'scripts'),
|
|
352
|
-
}
|
|
365
|
+
}
|
|
366
|
+
);
|
|
353
367
|
result.then(success, failure);
|
|
354
368
|
```
|
|
355
369
|
|
|
356
370
|
### `Command`
|
|
371
|
+
|
|
357
372
|
An object that contains all information about a spawned command, and ways to interact with it.<br>
|
|
358
373
|
It has the following properties:
|
|
359
374
|
|
|
@@ -376,6 +391,7 @@ It has the following properties:
|
|
|
376
391
|
- `kill([signal])`: kills the command, optionally specifying a signal (e.g. `SIGTERM`, `SIGKILL`, etc).
|
|
377
392
|
|
|
378
393
|
### `CloseEvent`
|
|
394
|
+
|
|
379
395
|
An object with information about a command's closing event.<br>
|
|
380
396
|
It contains the following properties:
|
|
381
397
|
|
|
@@ -387,19 +403,18 @@ It contains the following properties:
|
|
|
387
403
|
|
|
388
404
|
## FAQ
|
|
389
405
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
From [Node child_process documentation](http://nodejs.org/api/child_process.html#child_process_event_exit), `exit` event:
|
|
406
|
+
- Process exited with code _null_?
|
|
393
407
|
|
|
394
|
-
|
|
395
|
-
> terminated normally, code is the final exit code of the process,
|
|
396
|
-
> otherwise null. If the process terminated due to receipt of a signal,
|
|
397
|
-
> signal is the string name of the signal, otherwise null.
|
|
408
|
+
From [Node child_process documentation](http://nodejs.org/api/child_process.html#child_process_event_exit), `exit` event:
|
|
398
409
|
|
|
410
|
+
> This event is emitted after the child process ends. If the process
|
|
411
|
+
> terminated normally, code is the final exit code of the process,
|
|
412
|
+
> otherwise null. If the process terminated due to receipt of a signal,
|
|
413
|
+
> signal is the string name of the signal, otherwise null.
|
|
399
414
|
|
|
400
|
-
|
|
401
|
-
|
|
415
|
+
So _null_ means the process didn't terminate normally. This will make **concurrently**
|
|
416
|
+
to return non-zero exit code too.
|
|
402
417
|
|
|
403
|
-
|
|
418
|
+
- Does this work with the npm-replacements [yarn](https://github.com/yarnpkg/yarn) or [pnpm](https://pnpm.js.org/)?
|
|
404
419
|
|
|
405
|
-
|
|
420
|
+
Yes! In all examples above, you may replace "`npm`" with "`yarn`" or "`pnpm`".
|
package/dist/bin/concurrently.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
5
|
-
Object.
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
6
10
|
}) : (function(o, m, k, k2) {
|
|
7
11
|
if (k2 === undefined) k2 = k;
|
|
8
12
|
o[k2] = m[k];
|
|
@@ -31,7 +35,7 @@ const epilogue_1 = require("./epilogue");
|
|
|
31
35
|
// Clean-up arguments (yargs expects only the arguments after the program name)
|
|
32
36
|
const cleanArgs = (0, helpers_1.hideBin)(process.argv);
|
|
33
37
|
// Find argument separator (double dash)
|
|
34
|
-
const argsSepIdx = cleanArgs.findIndex(
|
|
38
|
+
const argsSepIdx = cleanArgs.findIndex(arg => arg === '--');
|
|
35
39
|
// Arguments before separator
|
|
36
40
|
const argsBeforeSep = argsSepIdx >= 0 ? cleanArgs.slice(0, argsSepIdx) : cleanArgs;
|
|
37
41
|
// Arguments after separator
|
|
@@ -53,7 +57,7 @@ const args = (0, yargs_1.default)(argsBeforeSep)
|
|
|
53
57
|
'New processes only spawn after all restart tries of a process.',
|
|
54
58
|
type: 'number',
|
|
55
59
|
},
|
|
56
|
-
|
|
60
|
+
names: {
|
|
57
61
|
alias: 'n',
|
|
58
62
|
describe: 'List of custom names to be used in prefix template.\n' +
|
|
59
63
|
'Example names: "main,browser,server"',
|
|
@@ -64,7 +68,7 @@ const args = (0, yargs_1.default)(argsBeforeSep)
|
|
|
64
68
|
'concurrently -n "styles|scripts|server" --name-separator "|"',
|
|
65
69
|
default: defaults.nameSeparator,
|
|
66
70
|
},
|
|
67
|
-
|
|
71
|
+
success: {
|
|
68
72
|
alias: 's',
|
|
69
73
|
describe: 'Which command(s) must exit with code 0 in order for concurrently exit with ' +
|
|
70
74
|
'code 0 too. Options are:\n' +
|
|
@@ -77,7 +81,7 @@ const args = (0, yargs_1.default)(argsBeforeSep)
|
|
|
77
81
|
'name or index.\n',
|
|
78
82
|
default: defaults.success,
|
|
79
83
|
},
|
|
80
|
-
|
|
84
|
+
raw: {
|
|
81
85
|
alias: 'r',
|
|
82
86
|
describe: 'Output only raw output of processes, disables prettifying ' +
|
|
83
87
|
'and concurrently coloring.',
|
|
@@ -89,18 +93,18 @@ const args = (0, yargs_1.default)(argsBeforeSep)
|
|
|
89
93
|
describe: 'Disables colors from logging',
|
|
90
94
|
type: 'boolean',
|
|
91
95
|
},
|
|
92
|
-
|
|
96
|
+
hide: {
|
|
93
97
|
describe: 'Comma-separated list of processes to hide the output.\n' +
|
|
94
98
|
'The processes can be identified by their name or index.',
|
|
95
99
|
default: defaults.hide,
|
|
96
100
|
type: 'string',
|
|
97
101
|
},
|
|
98
|
-
|
|
102
|
+
group: {
|
|
99
103
|
alias: 'g',
|
|
100
104
|
describe: 'Order the output as if the commands were run sequentially.',
|
|
101
105
|
type: 'boolean',
|
|
102
106
|
},
|
|
103
|
-
|
|
107
|
+
timings: {
|
|
104
108
|
describe: 'Show timing information for all processes.',
|
|
105
109
|
type: 'boolean',
|
|
106
110
|
default: defaults.timings,
|
|
@@ -123,7 +127,7 @@ const args = (0, yargs_1.default)(argsBeforeSep)
|
|
|
123
127
|
type: 'boolean',
|
|
124
128
|
},
|
|
125
129
|
// Prefix
|
|
126
|
-
|
|
130
|
+
prefix: {
|
|
127
131
|
alias: 'p',
|
|
128
132
|
describe: 'Prefix used in logging for each process.\n' +
|
|
129
133
|
'Possible values: index, pid, time, command, name, none, or a template. ' +
|
|
@@ -201,7 +205,9 @@ const commands = args.passthroughArguments ? args._ : [...args._, ...argsAfterSe
|
|
|
201
205
|
defaultInputTarget: args.defaultInputTarget,
|
|
202
206
|
killOthers: args.killOthers
|
|
203
207
|
? ['success', 'failure']
|
|
204
|
-
:
|
|
208
|
+
: args.killOthersOnFail
|
|
209
|
+
? ['failure']
|
|
210
|
+
: [],
|
|
205
211
|
maxProcesses: args.maxProcesses,
|
|
206
212
|
raw: args.raw,
|
|
207
213
|
hide: args.hide.split(','),
|
package/dist/bin/epilogue.js
CHANGED
|
@@ -33,17 +33,11 @@ const examples = [
|
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
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'),
|
|
36
|
+
example: ['$ $0 --handle-input "npm run watch-js" nodemon', '1:rs'].join('\n'),
|
|
40
37
|
},
|
|
41
38
|
{
|
|
42
39
|
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'),
|
|
40
|
+
example: ['$ $0 --handle-input -n js,srv "npm run watch-js" nodemon', 'srv:rs'].join('\n'),
|
|
47
41
|
},
|
|
48
42
|
{
|
|
49
43
|
description: 'Shortened NPM run commands',
|
|
@@ -58,24 +52,31 @@ const examples = [
|
|
|
58
52
|
example: '$ $0 "npm:*(!fix)"',
|
|
59
53
|
},
|
|
60
54
|
{
|
|
61
|
-
description:
|
|
55
|
+
description: "Passthrough some additional arguments via '{<number>}' placeholder",
|
|
62
56
|
example: '$ $0 -P "echo {1}" -- foo',
|
|
63
57
|
},
|
|
64
58
|
{
|
|
65
|
-
description:
|
|
59
|
+
description: "Passthrough all additional arguments via '{@}' placeholder",
|
|
66
60
|
example: '$ $0 -P "npm:dev-* -- {@}" -- --watch --noEmit',
|
|
67
61
|
},
|
|
68
62
|
{
|
|
69
|
-
description:
|
|
63
|
+
description: "Passthrough all additional arguments combined via '{*}' placeholder",
|
|
70
64
|
example: '$ $0 -P "npm:dev-* -- {*}" -- --watch --noEmit',
|
|
71
65
|
},
|
|
72
66
|
];
|
|
67
|
+
const examplesString = examples
|
|
68
|
+
.map(({ example, description }) => [
|
|
69
|
+
` - ${description}`,
|
|
70
|
+
example
|
|
71
|
+
.split('\n')
|
|
72
|
+
.map(line => ` ${line}`)
|
|
73
|
+
.join('\n'),
|
|
74
|
+
].join('\n\n'))
|
|
75
|
+
.join('\n\n');
|
|
73
76
|
exports.epilogue = `
|
|
74
77
|
Examples:
|
|
75
|
-
${examples.map(({ example, description }) => `
|
|
76
|
-
- ${description}
|
|
77
78
|
|
|
78
|
-
${
|
|
79
|
-
|
|
79
|
+
${examplesString}
|
|
80
|
+
|
|
80
81
|
For more details, visit https://github.com/open-cli-tools/concurrently
|
|
81
82
|
`;
|
|
@@ -6,7 +6,11 @@ import { CommandParser } from './command-parser';
|
|
|
6
6
|
export declare class ExpandArguments implements CommandParser {
|
|
7
7
|
private readonly additionalArguments;
|
|
8
8
|
constructor(additionalArguments: string[]);
|
|
9
|
-
parse(commandInfo: CommandInfo):
|
|
9
|
+
parse(commandInfo: CommandInfo): {
|
|
10
10
|
command: string;
|
|
11
|
+
name: string;
|
|
12
|
+
env?: Record<string, unknown>;
|
|
13
|
+
cwd?: string;
|
|
14
|
+
prefixColor?: string;
|
|
11
15
|
};
|
|
12
16
|
}
|
|
@@ -10,10 +10,10 @@ class ExpandArguments {
|
|
|
10
10
|
this.additionalArguments = additionalArguments;
|
|
11
11
|
}
|
|
12
12
|
parse(commandInfo) {
|
|
13
|
-
const command = commandInfo.command.replace(/\\?\{([
|
|
13
|
+
const command = commandInfo.command.replace(/\\?\{([@*]|[1-9][0-9]*)\}/g, (match, placeholderTarget) => {
|
|
14
14
|
// Don't replace the placeholder if it is escaped by a backslash.
|
|
15
15
|
if (match.startsWith('\\')) {
|
|
16
|
-
return match.
|
|
16
|
+
return match.slice(1);
|
|
17
17
|
}
|
|
18
18
|
// Replace numeric placeholder if value exists in additional arguments.
|
|
19
19
|
if (!isNaN(placeholderTarget) &&
|
|
@@ -32,9 +32,7 @@ class ExpandArguments {
|
|
|
32
32
|
// if value doesn't exist in additional arguments.
|
|
33
33
|
return '';
|
|
34
34
|
});
|
|
35
|
-
return
|
|
36
|
-
command,
|
|
37
|
-
});
|
|
35
|
+
return { ...commandInfo, command };
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
exports.ExpandArguments = ExpandArguments;
|
|
@@ -10,11 +10,11 @@ class ExpandNpmShortcut {
|
|
|
10
10
|
if (!cmdName) {
|
|
11
11
|
return commandInfo;
|
|
12
12
|
}
|
|
13
|
-
return
|
|
13
|
+
return {
|
|
14
|
+
...commandInfo,
|
|
14
15
|
name: commandInfo.name || cmdName,
|
|
15
16
|
command: `${npmCmd} run ${cmdName}${args}`,
|
|
16
|
-
}
|
|
17
|
+
};
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
exports.ExpandNpmShortcut = ExpandNpmShortcut;
|
|
20
|
-
;
|
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
21
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
6
|
exports.ExpandNpmWildcard = void 0;
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const OMISSION = /\(!([
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
const OMISSION = /\(!([^)]+)\)/;
|
|
26
10
|
/**
|
|
27
11
|
* Finds wildcards in npm/yarn/pnpm run commands and replaces them with all matching scripts in the
|
|
28
12
|
* `package.json` file of the current directory.
|
|
@@ -33,7 +17,7 @@ class ExpandNpmWildcard {
|
|
|
33
17
|
}
|
|
34
18
|
static readPackage() {
|
|
35
19
|
try {
|
|
36
|
-
const json =
|
|
20
|
+
const json = fs_1.default.readFileSync('package.json', { encoding: 'utf-8' });
|
|
37
21
|
return JSON.parse(json);
|
|
38
22
|
}
|
|
39
23
|
catch (e) {
|
|
@@ -53,8 +37,8 @@ class ExpandNpmWildcard {
|
|
|
53
37
|
}
|
|
54
38
|
const omissionRegex = cmdName.match(OMISSION);
|
|
55
39
|
const cmdNameSansOmission = cmdName.replace(OMISSION, '');
|
|
56
|
-
const preWildcard =
|
|
57
|
-
const postWildcard =
|
|
40
|
+
const preWildcard = lodash_1.default.escapeRegExp(cmdNameSansOmission.slice(0, wildcardPosition));
|
|
41
|
+
const postWildcard = lodash_1.default.escapeRegExp(cmdNameSansOmission.slice(wildcardPosition + 1));
|
|
58
42
|
const wildcardRegex = new RegExp(`^${preWildcard}(.*?)${postWildcard}$`);
|
|
59
43
|
const currentName = commandInfo.name || '';
|
|
60
44
|
return this.scripts
|
|
@@ -67,16 +51,16 @@ class ExpandNpmWildcard {
|
|
|
67
51
|
}
|
|
68
52
|
}
|
|
69
53
|
if (match) {
|
|
70
|
-
return
|
|
54
|
+
return {
|
|
55
|
+
...commandInfo,
|
|
71
56
|
command: `${npmCmd} run ${script}${args}`,
|
|
72
57
|
// Will use an empty command name if command has no name and the wildcard match is empty,
|
|
73
58
|
// e.g. if `npm:watch-*` matches `npm run watch-`.
|
|
74
59
|
name: currentName + match[1],
|
|
75
|
-
}
|
|
60
|
+
};
|
|
76
61
|
}
|
|
77
62
|
})
|
|
78
63
|
.filter((commandInfo) => !!commandInfo);
|
|
79
64
|
}
|
|
80
65
|
}
|
|
81
66
|
exports.ExpandNpmWildcard = ExpandNpmWildcard;
|
|
82
|
-
;
|
|
@@ -4,7 +4,11 @@ import { CommandParser } from './command-parser';
|
|
|
4
4
|
* Strips quotes around commands so that they can run on the current shell.
|
|
5
5
|
*/
|
|
6
6
|
export declare class StripQuotes implements CommandParser {
|
|
7
|
-
parse(commandInfo: CommandInfo):
|
|
7
|
+
parse(commandInfo: CommandInfo): {
|
|
8
8
|
command: string;
|
|
9
|
+
name: string;
|
|
10
|
+
env?: Record<string, unknown>;
|
|
11
|
+
cwd?: string;
|
|
12
|
+
prefixColor?: string;
|
|
9
13
|
};
|
|
10
14
|
}
|
|
@@ -9,10 +9,9 @@ class StripQuotes {
|
|
|
9
9
|
let { command } = commandInfo;
|
|
10
10
|
// Removes the quotes surrounding a command.
|
|
11
11
|
if (/^"(.+?)"$/.test(command) || /^'(.+?)'$/.test(command)) {
|
|
12
|
-
command = command.
|
|
12
|
+
command = command.slice(1, command.length - 1);
|
|
13
13
|
}
|
|
14
|
-
return
|
|
14
|
+
return { ...commandInfo, command };
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.StripQuotes = StripQuotes;
|
|
18
|
-
;
|
package/dist/src/command.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
2
5
|
import { ChildProcess as BaseChildProcess, SpawnOptions } from 'child_process';
|
|
3
6
|
import * as Rx from 'rxjs';
|
|
4
7
|
import { EventEmitter, Writable } from 'stream';
|
|
@@ -18,7 +21,7 @@ export interface CommandInfo {
|
|
|
18
21
|
/**
|
|
19
22
|
* Which environment variables should the spawned process have.
|
|
20
23
|
*/
|
|
21
|
-
env?: Record<string,
|
|
24
|
+
env?: Record<string, unknown>;
|
|
22
25
|
/**
|
|
23
26
|
* The current working directory of the process when spawned.
|
|
24
27
|
*/
|
|
@@ -76,7 +79,7 @@ export declare class Command implements CommandInfo {
|
|
|
76
79
|
/** @inheritdoc */
|
|
77
80
|
readonly prefixColor: string;
|
|
78
81
|
/** @inheritdoc */
|
|
79
|
-
readonly env: Record<string,
|
|
82
|
+
readonly env: Record<string, unknown>;
|
|
80
83
|
/** @inheritdoc */
|
|
81
84
|
readonly cwd?: string;
|
|
82
85
|
readonly close: Rx.Subject<CloseEvent>;
|
package/dist/src/command.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -73,7 +77,7 @@ class Command {
|
|
|
73
77
|
timings: {
|
|
74
78
|
startDate,
|
|
75
79
|
endDate,
|
|
76
|
-
durationSeconds: durationSeconds +
|
|
80
|
+
durationSeconds: durationSeconds + durationNanoSeconds / 1e9,
|
|
77
81
|
},
|
|
78
82
|
});
|
|
79
83
|
});
|
|
@@ -92,7 +96,6 @@ class Command {
|
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
exports.Command = Command;
|
|
95
|
-
;
|
|
96
99
|
/**
|
|
97
100
|
* Pipes all events emitted by `stream` into `subject`.
|
|
98
101
|
*/
|
|
@@ -12,11 +12,11 @@ import { CloseEvent, Command } from './command';
|
|
|
12
12
|
export declare type SuccessCondition = 'first' | 'last' | 'all' | `command-${string | number}` | `!command-${string | number}`;
|
|
13
13
|
/**
|
|
14
14
|
* Provides logic to determine whether lists of commands ran successfully.
|
|
15
|
-
*/
|
|
15
|
+
*/
|
|
16
16
|
export declare class CompletionListener {
|
|
17
17
|
private readonly successCondition;
|
|
18
18
|
private readonly scheduler?;
|
|
19
|
-
constructor({ successCondition, scheduler }: {
|
|
19
|
+
constructor({ successCondition, scheduler, }: {
|
|
20
20
|
/**
|
|
21
21
|
* How this instance will define that a list of commands ran successfully.
|
|
22
22
|
* Defaults to `all`.
|