concurrently 7.2.1 → 7.4.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.
Files changed (38) hide show
  1. package/README.md +87 -69
  2. package/dist/bin/concurrently.js +16 -10
  3. package/dist/bin/epilogue.js +16 -15
  4. package/dist/src/command-parser/expand-arguments.d.ts +5 -1
  5. package/dist/src/command-parser/expand-arguments.js +3 -5
  6. package/dist/src/command-parser/expand-npm-shortcut.js +3 -3
  7. package/dist/src/command-parser/expand-npm-wildcard.js +12 -28
  8. package/dist/src/command-parser/strip-quotes.d.ts +5 -1
  9. package/dist/src/command-parser/strip-quotes.js +2 -3
  10. package/dist/src/command.d.ts +5 -2
  11. package/dist/src/command.js +8 -5
  12. package/dist/src/completion-listener.d.ts +2 -2
  13. package/dist/src/completion-listener.js +14 -15
  14. package/dist/src/concurrently.js +14 -11
  15. package/dist/src/flow-control/input-handler.d.ts +1 -1
  16. package/dist/src/flow-control/input-handler.js +10 -7
  17. package/dist/src/flow-control/kill-on-signal.js +5 -6
  18. package/dist/src/flow-control/kill-others.d.ts +1 -1
  19. package/dist/src/flow-control/kill-others.js +6 -8
  20. package/dist/src/flow-control/log-error.js +2 -3
  21. package/dist/src/flow-control/log-exit.js +1 -2
  22. package/dist/src/flow-control/log-output.js +3 -4
  23. package/dist/src/flow-control/log-timings.d.ts +3 -3
  24. package/dist/src/flow-control/log-timings.js +13 -13
  25. package/dist/src/flow-control/restart-process.d.ts +1 -1
  26. package/dist/src/flow-control/restart-process.js +11 -6
  27. package/dist/src/get-spawn-opts.d.ts +4 -1
  28. package/dist/src/get-spawn-opts.js +9 -2
  29. package/dist/src/index.d.ts +1 -1
  30. package/dist/src/index.js +1 -1
  31. package/dist/src/logger.d.ts +2 -2
  32. package/dist/src/logger.js +16 -13
  33. package/dist/src/output-writer.d.ts +1 -1
  34. package/dist/src/output-writer.js +8 -6
  35. package/index.js +5 -3
  36. package/index.mjs +5 -4
  37. package/package.json +44 -33
  38. package/dist/.DS_Store +0 -0
package/README.md CHANGED
@@ -1,17 +1,19 @@
1
- # Concurrently
1
+ # concurrently
2
2
 
3
- [![Build Status](https://github.com/open-cli-tools/concurrently/workflows/Tests/badge.svg)](https://github.com/open-cli-tools/concurrently/actions?workflow=Tests)
4
- [![Coverage Status](https://coveralls.io/repos/github/open-cli-tools/concurrently/badge.svg?branch=master)](https://coveralls.io/github/open-cli-tools/concurrently?branch=master)
5
-
6
- [![NPM Badge](https://nodei.co/npm/concurrently.png?downloads=true)](https://www.npmjs.com/package/concurrently)
3
+ [![Latest Release](https://img.shields.io/github/v/release/open-cli-tools/concurrently?label=Release)](https://github.com/open-cli-tools/concurrently/releases)
4
+ [![License](https://img.shields.io/github/license/open-cli-tools/concurrently?label=License)](https://github.com/open-cli-tools/concurrently/blob/main/LICENSE)
5
+ [![Weekly Downloads on NPM](https://img.shields.io/npm/dw/concurrently?label=Downloads&logo=npm)](https://www.npmjs.com/package/concurrently)
6
+ [![CI Status](https://img.shields.io/github/workflow/status/open-cli-tools/concurrently/CI?label=CI&logo=github)](https://github.com/open-cli-tools/concurrently/actions/workflows/ci.yml)
7
+ [![Coverage Status](https://img.shields.io/coveralls/github/open-cli-tools/concurrently/main?label=Coverage&logo=coveralls)](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
- ![](docs/demo.gif)
12
+ ![Demo](docs/demo.gif)
13
+
14
+ **Table of Contents**
12
15
 
13
- **Table of contents**
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
- * Cross platform (including Windows)
38
- * Output is easy to follow with prefixes
39
- * With `--kill-others` switch, all commands are killed if one dies
40
- * Spawns commands with [spawn-command](https://github.com/mmalecki/spawn-command)
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
 
@@ -55,7 +57,11 @@ npm install concurrently --save
55
57
 
56
58
  ## Usage
57
59
 
60
+ > **Note**
61
+ > The `concurrently` command is now also available under the shorthand alias `conc`.
62
+
58
63
  Remember to surround separate commands with quotes:
64
+
59
65
  ```bash
60
66
  concurrently "command1 arg" "command2 arg"
61
67
  ```
@@ -81,17 +87,17 @@ concurrently -n watch-js,watch-css,watch-node "npm run watch-js" "npm run watch-
81
87
  NPM shortened commands also support wildcards. Given the following scripts in
82
88
  package.json:
83
89
 
84
- ```javascript
90
+ ```jsonc
85
91
  {
86
- //...
87
- "scripts": {
88
- // ...
89
- "watch-js": "...",
90
- "watch-css": "...",
91
- "watch-node": "...",
92
- // ...
93
- },
92
+ //...
93
+ "scripts": {
94
+ // ...
95
+ "watch-js": "...",
96
+ "watch-css": "...",
97
+ "watch-node": "..."
94
98
  // ...
99
+ }
100
+ // ...
95
101
  }
96
102
  ```
97
103
 
@@ -110,19 +116,21 @@ concurrently -n w:js,w:css,w:node "npm run watch-js" "npm run watch-css" "npm ru
110
116
  ```
111
117
 
112
118
  Exclusion is also supported. Given the following scripts in package.json:
113
- ```javascript
119
+
120
+ ```jsonc
114
121
  {
122
+ // ...
123
+ "scripts": {
124
+ "lint:js": "...",
125
+ "lint:ts": "...",
126
+ "lint:fix:js": "...",
127
+ "lint:fix:ts": "..."
115
128
  // ...
116
- "scripts": {
117
- "lint:js": "...",
118
- "lint:ts": "...",
119
- "lint:fix:js": "...",
120
- "lint:fix:ts": "...",
121
- // ...
122
- }
123
- // ...
129
+ }
130
+ // ...
124
131
  }
125
132
  ```
133
+
126
134
  ```bash
127
135
  # Running only lint:js and lint:ts
128
136
  # with lint:fix:js and lint:fix:ts excluded
@@ -144,8 +152,8 @@ General
144
152
  template.
145
153
  Example names: "main,browser,server" [string]
146
154
  --name-separator The character to split <names> on. Example usage:
147
- concurrently -n "styles|scripts|server"
148
- --name-separator "|" [default: ","]
155
+ -n "styles|scripts|server" --name-separator "|"
156
+ [default: ","]
149
157
  -s, --success Which command(s) must exit with code 0 in order
150
158
  for concurrently exit with code 0 too. Options
151
159
  are:
@@ -291,7 +299,8 @@ For more details, visit https://github.com/open-cli-tools/concurrently
291
299
  ```
292
300
 
293
301
  ## API
294
- concurrently can be used programmatically by using the API documented below:
302
+
303
+ **concurrently** can be used programmatically by using the API documented below:
295
304
 
296
305
  ### `concurrently(commands[, options])`
297
306
 
@@ -299,38 +308,39 @@ concurrently can be used programmatically by using the API documented below:
299
308
  with the shape `{ command, name, prefixColor, env, cwd }`.
300
309
 
301
310
  - `options` (optional): an object containing any of the below:
302
- - `cwd`: the working directory to be used by all commands. Can be overriden per command.
311
+ - `cwd`: the working directory to be used by all commands. Can be overriden per command.
303
312
  Default: `process.cwd()`.
304
- - `defaultInputTarget`: the default input target when reading from `inputStream`.
313
+ - `defaultInputTarget`: the default input target when reading from `inputStream`.
305
314
  Default: `0`.
306
- - `handleInput`: when `true`, reads input from `process.stdin`.
307
- - `inputStream`: a [`Readable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_readable_streams)
315
+ - `handleInput`: when `true`, reads input from `process.stdin`.
316
+ - `inputStream`: a [`Readable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_readable_streams)
308
317
  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
- - `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)).
310
- - `killOthers`: an array of exitting conditions that will cause a process to kill others.
318
+ - `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)).
319
+ - `killOthers`: an array of exitting conditions that will cause a process to kill others.
311
320
  Can contain any of `success` or `failure`.
312
- - `maxProcesses`: how many processes should run at once.
313
- - `outputStream`: a [`Writable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_writable_streams)
321
+ - `maxProcesses`: how many processes should run at once.
322
+ - `outputStream`: a [`Writable` stream](https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_writable_streams)
314
323
  to write logs to. Default: `process.stdout`.
315
- - `prefix`: the prefix type to use when logging processes output.
316
- Possible values: `index`, `pid`, `time`, `command`, `name`, `none`, or a template (eg `[{time} process: {pid}]`).
317
- Default: the name of the process, or its index if no name is set.
318
- - `prefixColors`: a list of colors as supported by [chalk](https://www.npmjs.com/package/chalk).
319
- If concurrently would run more commands than there are colors, the last color is repeated.
320
- Prefix colors specified per-command take precedence over this list.
321
- - `prefixLength`: how many characters to show when prefixing with `command`. Default: `10`
322
- - `raw`: whether raw mode should be used, meaning strictly process output will
324
+ - `prefix`: the prefix type to use when logging processes output.
325
+ Possible values: `index`, `pid`, `time`, `command`, `name`, `none`, or a template (eg `[{time} process: {pid}]`).
326
+ Default: the name of the process, or its index if no name is set.
327
+ - `prefixColors`: a list of colors as supported by [chalk](https://www.npmjs.com/package/chalk).
328
+ If concurrently would run more commands than there are colors, the last color is repeated.
329
+ Prefix colors specified per-command take precedence over this list.
330
+ - `prefixLength`: how many characters to show when prefixing with `command`. Default: `10`
331
+ - `raw`: whether raw mode should be used, meaning strictly process output will
323
332
  be logged, without any prefixes, colouring or extra stuff.
324
- - `successCondition`: the condition to consider the run was successful.
333
+ - `successCondition`: the condition to consider the run was successful.
325
334
  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
335
  Anything else means all processes should exit successfully.
327
- - `restartTries`: how many attempts to restart a process that dies will be made. Default: `0`.
328
- - `restartDelay`: how many milliseconds to wait between process restarts. Default: `0`.
329
- - `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format)
336
+ - `restartTries`: how many attempts to restart a process that dies will be made. Default: `0`.
337
+ - `restartDelay`: how many milliseconds to wait between process restarts. Default: `0`.
338
+ - `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format)
330
339
  to use when prefixing with `time`. Default: `yyyy-MM-dd HH:mm:ss.ZZZ`
331
- - `additionalArguments`: list of additional arguments passed that will get replaced in each command. If not defined, no argument replacing will happen.
340
+ - `additionalArguments`: list of additional arguments passed that will get replaced in each command. If not defined, no argument replacing will happen.
332
341
 
333
342
  > **Returns:** an object in the shape `{ result, commands }`.
343
+ >
334
344
  > - `result`: a `Promise` that resolves if the run was successful (according to `successCondition` option),
335
345
  > or rejects, containing an array of [`CloseEvent`](#CloseEvent), in the order that the commands terminated.
336
346
  > - `commands`: an array of all spawned [`Command`s](#Command).
@@ -339,21 +349,29 @@ Example:
339
349
 
340
350
  ```js
341
351
  const concurrently = require('concurrently');
342
- const { result } = concurrently([
352
+ const { result } = concurrently(
353
+ [
343
354
  'npm:watch-*',
344
355
  { command: 'nodemon', name: 'server' },
345
356
  { command: 'deploy', name: 'deploy', env: { PUBLIC_KEY: '...' } },
346
- { command: 'watch', name: 'watch', cwd: path.resolve(__dirname, 'scripts/watchers')}
347
- ], {
357
+ {
358
+ command: 'watch',
359
+ name: 'watch',
360
+ cwd: path.resolve(__dirname, 'scripts/watchers'),
361
+ },
362
+ ],
363
+ {
348
364
  prefix: 'name',
349
365
  killOthers: ['failure', 'success'],
350
366
  restartTries: 3,
351
367
  cwd: path.resolve(__dirname, 'scripts'),
352
- });
368
+ }
369
+ );
353
370
  result.then(success, failure);
354
371
  ```
355
372
 
356
373
  ### `Command`
374
+
357
375
  An object that contains all information about a spawned command, and ways to interact with it.<br>
358
376
  It has the following properties:
359
377
 
@@ -376,6 +394,7 @@ It has the following properties:
376
394
  - `kill([signal])`: kills the command, optionally specifying a signal (e.g. `SIGTERM`, `SIGKILL`, etc).
377
395
 
378
396
  ### `CloseEvent`
397
+
379
398
  An object with information about a command's closing event.<br>
380
399
  It contains the following properties:
381
400
 
@@ -387,19 +406,18 @@ It contains the following properties:
387
406
 
388
407
  ## FAQ
389
408
 
390
- * Process exited with code *null*?
391
-
392
- From [Node child_process documentation](http://nodejs.org/api/child_process.html#child_process_event_exit), `exit` event:
409
+ - Process exited with code _null_?
393
410
 
394
- > This event is emitted after the child process ends. If the process
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.
411
+ From [Node child_process documentation](http://nodejs.org/api/child_process.html#child_process_event_exit), `exit` event:
398
412
 
413
+ > This event is emitted after the child process ends. If the process
414
+ > terminated normally, code is the final exit code of the process,
415
+ > otherwise null. If the process terminated due to receipt of a signal,
416
+ > signal is the string name of the signal, otherwise null.
399
417
 
400
- So *null* means the process didn't terminate normally. This will make **concurrent**
401
- to return non-zero exit code too.
418
+ So _null_ means the process didn't terminate normally. This will make **concurrently**
419
+ to return non-zero exit code too.
402
420
 
403
- * Does this work with the npm-replacements [yarn](https://github.com/yarnpkg/yarn) or [pnpm](https://pnpm.js.org/)?
421
+ - Does this work with the npm-replacements [yarn](https://github.com/yarnpkg/yarn) or [pnpm](https://pnpm.js.org/)?
404
422
 
405
- Yes! In all examples above, you may replace "`npm`" with "`yarn`" or "`pnpm`".
423
+ Yes! In all examples above, you may replace "`npm`" with "`yarn`" or "`pnpm`".
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -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
- 'names': {
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"',
@@ -61,10 +65,10 @@ const args = (0, yargs_1.default)(argsBeforeSep)
61
65
  },
62
66
  'name-separator': {
63
67
  describe: 'The character to split <names> on. Example usage:\n' +
64
- 'concurrently -n "styles|scripts|server" --name-separator "|"',
68
+ '-n "styles|scripts|server" --name-separator "|"',
65
69
  default: defaults.nameSeparator,
66
70
  },
67
- 'success': {
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
- 'raw': {
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
- 'hide': {
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
- 'group': {
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
- 'timings': {
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
- 'prefix': {
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
- : (args.killOthersOnFail ? ['failure'] : []),
208
+ : args.killOthersOnFail
209
+ ? ['failure']
210
+ : [],
205
211
  maxProcesses: args.maxProcesses,
206
212
  raw: args.raw,
207
213
  hide: args.hide.split(','),
@@ -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: 'Passthrough some additional arguments via \'{<number>}\' placeholder',
55
+ description: "Passthrough some additional arguments via '{<number>}' placeholder",
62
56
  example: '$ $0 -P "echo {1}" -- foo',
63
57
  },
64
58
  {
65
- description: 'Passthrough all additional arguments via \'{@}\' placeholder',
59
+ description: "Passthrough all additional arguments via '{@}' placeholder",
66
60
  example: '$ $0 -P "npm:dev-* -- {@}" -- --watch --noEmit',
67
61
  },
68
62
  {
69
- description: 'Passthrough all additional arguments combined via \'{*}\' placeholder',
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
- ${example.split('\n').map(line => ` ${line}`).join('\n')}
79
- `).join('')}
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): 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(/\\?\{([@\*]|[1-9][0-9]*)\}/g, (match, placeholderTarget) => {
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.substring(1);
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 Object.assign({}, commandInfo, {
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 Object.assign({}, commandInfo, {
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 __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;
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 fs = __importStar(require("fs"));
24
- const _ = __importStar(require("lodash"));
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 = fs.readFileSync('package.json', { encoding: 'utf-8' });
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,12 +37,12 @@ class ExpandNpmWildcard {
53
37
  }
54
38
  const omissionRegex = cmdName.match(OMISSION);
55
39
  const cmdNameSansOmission = cmdName.replace(OMISSION, '');
56
- const preWildcard = _.escapeRegExp(cmdNameSansOmission.substr(0, wildcardPosition));
57
- const postWildcard = _.escapeRegExp(cmdNameSansOmission.substr(wildcardPosition + 1));
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
61
- .map(script => {
45
+ .map((script) => {
62
46
  const match = script.match(wildcardRegex);
63
47
  if (omissionRegex) {
64
48
  const toOmit = script.match(new RegExp(omissionRegex[1]));
@@ -67,16 +51,16 @@ class ExpandNpmWildcard {
67
51
  }
68
52
  }
69
53
  if (match) {
70
- return Object.assign({}, commandInfo, {
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): 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.substring(1, command.length - 1);
12
+ command = command.slice(1, command.length - 1);
13
13
  }
14
- return Object.assign({}, commandInfo, { command });
14
+ return { ...commandInfo, command };
15
15
  }
16
16
  }
17
17
  exports.StripQuotes = StripQuotes;
18
- ;
@@ -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, any>;
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, any>;
82
+ readonly env: Record<string, unknown>;
80
83
  /** @inheritdoc */
81
84
  readonly cwd?: string;
82
85
  readonly close: Rx.Subject<CloseEvent>;
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -53,7 +57,7 @@ class Command {
53
57
  const startDate = new Date(Date.now());
54
58
  const highResStartTime = process.hrtime();
55
59
  this.timer.next({ startDate });
56
- Rx.fromEvent(child, 'error').subscribe(event => {
60
+ Rx.fromEvent(child, 'error').subscribe((event) => {
57
61
  this.process = undefined;
58
62
  const endDate = new Date(Date.now());
59
63
  this.timer.next({ startDate, endDate });
@@ -73,7 +77,7 @@ class Command {
73
77
  timings: {
74
78
  startDate,
75
79
  endDate,
76
- durationSeconds: durationSeconds + (durationNanoSeconds / 1e9),
80
+ durationSeconds: durationSeconds + durationNanoSeconds / 1e9,
77
81
  },
78
82
  });
79
83
  });
@@ -92,10 +96,9 @@ 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
  */
99
102
  function pipeTo(stream, subject) {
100
- stream.subscribe(event => subject.next(event));
103
+ stream.subscribe((event) => subject.next(event));
101
104
  }
@@ -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`.