concurrently 6.5.1 → 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.
Files changed (100) hide show
  1. package/README.md +58 -19
  2. package/dist/bin/concurrently.d.ts +2 -0
  3. package/dist/bin/concurrently.js +193 -0
  4. package/dist/bin/concurrently.spec.d.ts +1 -0
  5. package/dist/bin/epilogue.d.ts +1 -0
  6. package/dist/bin/epilogue.js +65 -0
  7. package/dist/src/command-parser/command-parser.d.ts +19 -0
  8. package/dist/src/command-parser/command-parser.js +2 -0
  9. package/dist/src/command-parser/expand-npm-shortcut.d.ts +8 -0
  10. package/{src → dist/src}/command-parser/expand-npm-shortcut.js +10 -3
  11. package/dist/src/command-parser/expand-npm-shortcut.spec.d.ts +1 -0
  12. package/dist/src/command-parser/expand-npm-wildcard.d.ts +13 -0
  13. package/dist/src/command-parser/expand-npm-wildcard.js +73 -0
  14. package/dist/src/command-parser/expand-npm-wildcard.spec.d.ts +1 -0
  15. package/dist/src/command-parser/strip-quotes.d.ts +10 -0
  16. package/{src → dist/src}/command-parser/strip-quotes.js +10 -4
  17. package/dist/src/command-parser/strip-quotes.spec.d.ts +1 -0
  18. package/dist/src/command.d.ts +101 -0
  19. package/{src → dist/src}/command.js +53 -29
  20. package/dist/src/command.spec.d.ts +1 -0
  21. package/dist/src/completion-listener.d.ts +37 -0
  22. package/dist/src/completion-listener.js +60 -0
  23. package/dist/src/completion-listener.spec.d.ts +1 -0
  24. package/dist/src/concurrently.d.ts +77 -0
  25. package/dist/src/concurrently.js +120 -0
  26. package/dist/src/concurrently.spec.d.ts +1 -0
  27. package/dist/src/defaults.d.ts +52 -0
  28. package/dist/src/defaults.js +58 -0
  29. package/dist/src/flow-control/flow-controller.d.ts +13 -0
  30. package/dist/src/flow-control/flow-controller.js +2 -0
  31. package/dist/src/flow-control/input-handler.d.ts +33 -0
  32. package/dist/src/flow-control/input-handler.js +73 -0
  33. package/dist/src/flow-control/input-handler.spec.d.ts +1 -0
  34. package/dist/src/flow-control/kill-on-signal.d.ts +17 -0
  35. package/{src → dist/src}/flow-control/kill-on-signal.js +13 -11
  36. package/dist/src/flow-control/kill-on-signal.spec.d.ts +1 -0
  37. package/dist/src/flow-control/kill-others.d.ts +18 -0
  38. package/dist/src/flow-control/kill-others.js +35 -0
  39. package/dist/src/flow-control/kill-others.spec.d.ts +1 -0
  40. package/dist/src/flow-control/log-error.d.ts +15 -0
  41. package/dist/src/flow-control/log-error.js +21 -0
  42. package/dist/src/flow-control/log-error.spec.d.ts +1 -0
  43. package/dist/src/flow-control/log-exit.d.ts +15 -0
  44. package/dist/src/flow-control/log-exit.js +19 -0
  45. package/dist/src/flow-control/log-exit.spec.d.ts +1 -0
  46. package/dist/src/flow-control/log-output.d.ts +15 -0
  47. package/{src → dist/src}/flow-control/log-output.js +13 -5
  48. package/dist/src/flow-control/log-output.spec.d.ts +1 -0
  49. package/dist/src/flow-control/log-timings.d.ts +27 -0
  50. package/dist/src/flow-control/log-timings.js +88 -0
  51. package/dist/src/flow-control/log-timings.spec.d.ts +1 -0
  52. package/dist/src/flow-control/restart-process.d.ts +22 -0
  53. package/dist/src/flow-control/restart-process.js +71 -0
  54. package/dist/src/flow-control/restart-process.spec.d.ts +1 -0
  55. package/dist/src/get-spawn-opts.d.ts +30 -0
  56. package/dist/src/get-spawn-opts.js +11 -0
  57. package/dist/src/get-spawn-opts.spec.d.ts +1 -0
  58. package/dist/src/index.d.ts +69 -0
  59. package/dist/src/index.js +69 -0
  60. package/dist/src/logger.d.ts +72 -0
  61. package/{src → dist/src}/logger.js +77 -58
  62. package/dist/src/logger.spec.d.ts +1 -0
  63. package/dist/src/output-writer.d.ts +19 -0
  64. package/dist/src/output-writer.js +69 -0
  65. package/dist/src/output-writer.spec.d.ts +1 -0
  66. package/index.js +6 -68
  67. package/index.mjs +9 -0
  68. package/package.json +37 -11
  69. package/bin/concurrently.js +0 -186
  70. package/bin/concurrently.spec.js +0 -428
  71. package/bin/epilogue.txt +0 -46
  72. package/src/command-parser/expand-npm-shortcut.spec.js +0 -36
  73. package/src/command-parser/expand-npm-wildcard.js +0 -52
  74. package/src/command-parser/expand-npm-wildcard.spec.js +0 -104
  75. package/src/command-parser/strip-quotes.spec.js +0 -20
  76. package/src/command.spec.js +0 -275
  77. package/src/completion-listener.js +0 -39
  78. package/src/completion-listener.spec.js +0 -89
  79. package/src/concurrently.js +0 -116
  80. package/src/concurrently.spec.js +0 -199
  81. package/src/defaults.js +0 -35
  82. package/src/flow-control/base-handler.js +0 -16
  83. package/src/flow-control/base-handler.spec.js +0 -22
  84. package/src/flow-control/input-handler.js +0 -50
  85. package/src/flow-control/input-handler.spec.js +0 -113
  86. package/src/flow-control/kill-on-signal.spec.js +0 -79
  87. package/src/flow-control/kill-others.js +0 -38
  88. package/src/flow-control/kill-others.spec.js +0 -66
  89. package/src/flow-control/log-error.js +0 -18
  90. package/src/flow-control/log-error.spec.js +0 -40
  91. package/src/flow-control/log-exit.js +0 -11
  92. package/src/flow-control/log-exit.spec.js +0 -36
  93. package/src/flow-control/log-output.spec.js +0 -41
  94. package/src/flow-control/log-timings.js +0 -64
  95. package/src/flow-control/log-timings.spec.js +0 -137
  96. package/src/flow-control/restart-process.js +0 -56
  97. package/src/flow-control/restart-process.spec.js +0 -139
  98. package/src/get-spawn-opts.js +0 -16
  99. package/src/get-spawn-opts.spec.js +0 -30
  100. package/src/logger.spec.js +0 -318
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
- - [Programmatic Usage](#programmatic-usage)
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
@@ -135,6 +137,10 @@ General
135
137
  --hide Comma-separated list of processes to hide the output.
136
138
  The processes can be identified by their name or index.
137
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]
138
144
 
139
145
  Prefix styling
140
146
  -p, --prefix Prefix used in logging for each process.
@@ -147,12 +153,12 @@ Prefix styling
147
153
  - Available modifiers: reset, bold, dim, italic,
148
154
  underline, inverse, hidden, strikethrough
149
155
  - Available colors: black, red, green, yellow, blue,
150
- magenta, cyan, white, gray, or any hex values for
151
- colors, eg #23de43
156
+ magenta, cyan, white, gray
157
+ or any hex values for colors, eg #23de43
152
158
  - Available background colors: bgBlack, bgRed,
153
159
  bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite
154
160
  See https://www.npmjs.com/package/chalk for more
155
- information. [string] [default: "reset"]
161
+ information. [string] [default: "reset"]
156
162
  -l, --prefix-length Limit how many characters of the command is displayed
157
163
  in prefix. The option can be used to shorten the
158
164
  prefix when it is set to "command"
@@ -161,17 +167,19 @@ Prefix styling
161
167
  [string] [default: "yyyy-MM-dd HH:mm:ss.SSS"]
162
168
 
163
169
  Input handling
164
- -i, --handle-input Whether input should be forwarded to the child
165
- processes. See examples for more information.[boolean]
166
- --default-input-target Identifier for child process to which input on stdin
167
- should be sent if not specified at start of input.
168
- Can be either the index or the name of the process.
169
- [default: 0]
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]
170
178
 
171
179
  Killing other processes
172
- -k, --kill-others kill other processes if one exits or dies [boolean]
173
- --kill-others-on-fail kill other processes if one exits with non zero status
174
- code [boolean]
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]
175
183
 
176
184
  Restarting
177
185
  --restart-tries How many times a process that died should restart.
@@ -233,7 +241,7 @@ Examples:
233
241
  For more details, visit https://github.com/open-cli-tools/concurrently
234
242
  ```
235
243
 
236
- ## Programmatic Usage
244
+ ## API
237
245
  concurrently can be used programmatically by using the API documented below:
238
246
 
239
247
  ### `concurrently(commands[, options])`
@@ -272,11 +280,10 @@ concurrently can be used programmatically by using the API documented below:
272
280
  - `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format)
273
281
  to use when prefixing with `time`. Default: `yyyy-MM-dd HH:mm:ss.ZZZ`
274
282
 
275
- > Returns: a `Promise` that resolves if the run was successful (according to `successCondition` option),
276
- > or rejects, containing an array of objects with information for each command that has been run, in the order
277
- > that the commands terminated. The objects have the shape `{ command, index, exitCode, killed }`, where `command` is the object
278
- > passed in the `commands` array, `index` its index there and `killed` indicates if the process was killed as a result of
279
- > `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).
280
287
 
281
288
  Example:
282
289
 
@@ -295,6 +302,38 @@ concurrently([
295
302
  }).then(success, failure);
296
303
  ```
297
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
+
298
337
  ## FAQ
299
338
 
300
339
  * Process exited with code *null*?
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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
- module.exports = class ExpandNpmShortcut {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpandNpmShortcut = void 0;
4
+ /**
5
+ * Expands commands prefixed with `npm:`, `yarn:` or `pnpm:` into the full version `npm run <command>` and so on.
6
+ */
7
+ class ExpandNpmShortcut {
2
8
  parse(commandInfo) {
3
9
  const [, npmCmd, cmdName, args] = commandInfo.command.match(/^(npm|yarn|pnpm):(\S+)(.*)/) || [];
4
10
  if (!cmdName) {
5
11
  return commandInfo;
6
12
  }
7
-
8
13
  return Object.assign({}, commandInfo, {
9
14
  name: commandInfo.name || cmdName,
10
15
  command: `${npmCmd} run ${cmdName}${args}`
11
16
  });
12
17
  }
13
- };
18
+ }
19
+ exports.ExpandNpmShortcut = ExpandNpmShortcut;
20
+ ;
@@ -0,0 +1,13 @@
1
+ import { CommandInfo } from '../command';
2
+ import { CommandParser } from './command-parser';
3
+ /**
4
+ * Finds wildcards in npm/yarn/pnpm run commands and replaces them with all matching scripts in the
5
+ * `package.json` file of the current directory.
6
+ */
7
+ export declare class ExpandNpmWildcard implements CommandParser {
8
+ private readonly readPackage;
9
+ static readPackage(): any;
10
+ private scripts?;
11
+ constructor(readPackage?: typeof ExpandNpmWildcard.readPackage);
12
+ parse(commandInfo: CommandInfo): CommandInfo | CommandInfo[];
13
+ }
@@ -0,0 +1,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,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
- module.exports = class StripQuotes {
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 {};