concurrently 7.1.0 → 7.2.2

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 CHANGED
@@ -134,33 +134,43 @@ Good frontend one-liner example [here](https://github.com/kimmobrunfeldt/dont-co
134
134
  Help:
135
135
 
136
136
  ```
137
-
138
137
  concurrently [options] <command ...>
139
138
 
140
139
  General
141
- -m, --max-processes How many processes should run at once.
142
- New processes only spawn after all restart tries of a
143
- process. [number]
144
- -n, --names List of custom names to be used in prefix template.
145
- Example names: "main,browser,server" [string]
146
- --name-separator The character to split <names> on. Example usage:
147
- concurrently -n "styles|scripts|server" --name-separator
148
- "|" [default: ","]
149
- -r, --raw Output only raw output of processes, disables
150
- prettifying and concurrently coloring. [boolean]
151
- -s, --success Return exit code of zero or one based on the success or
152
- failure of the "first" child to terminate, the "last
153
- child", or succeed only if "all" child processes
154
- succeed.
155
- [choices: "first", "last", "all"] [default: "all"]
156
- --no-color Disables colors from logging [boolean]
157
- --hide Comma-separated list of processes to hide the output.
158
- The processes can be identified by their name or index.
159
- [string] [default: ""]
160
- -g, --group Order the output as if the commands were run
161
- sequentially. [boolean]
162
- --timings Show timing information for all processes
140
+ -m, --max-processes How many processes should run at once.
141
+ New processes only spawn after all restart tries
142
+ of a process. [number]
143
+ -n, --names List of custom names to be used in prefix
144
+ template.
145
+ Example names: "main,browser,server" [string]
146
+ --name-separator The character to split <names> on. Example usage:
147
+ concurrently -n "styles|scripts|server"
148
+ --name-separator "|" [default: ","]
149
+ -s, --success Which command(s) must exit with code 0 in order
150
+ for concurrently exit with code 0 too. Options
151
+ are:
152
+ - "first" for the first command to exit;
153
+ - "last" for the last command to exit;
154
+ - "all" for all commands;
155
+ - "command-{name}"/"command-{index}" for the
156
+ commands with that name or index;
157
+ - "!command-{name}"/"!command-{index}" for all
158
+ commands but the ones with that name or index.
159
+ [default: "all"]
160
+ -r, --raw Output only raw output of processes, disables
161
+ prettifying and concurrently coloring. [boolean]
162
+ --no-color Disables colors from logging [boolean]
163
+ --hide Comma-separated list of processes to hide the
164
+ output.
165
+ The processes can be identified by their name or
166
+ index. [string] [default: ""]
167
+ -g, --group Order the output as if the commands were run
168
+ sequentially. [boolean]
169
+ --timings Show timing information for all processes.
163
170
  [boolean] [default: false]
171
+ -P, --passthrough-arguments Passthrough additional arguments to commands
172
+ (accessible via placeholders) instead of treating
173
+ them as commands. [boolean] [default: false]
164
174
 
165
175
  Prefix styling
166
176
  -p, --prefix Prefix used in logging for each process.
@@ -197,9 +207,9 @@ Input handling
197
207
  process. [default: 0]
198
208
 
199
209
  Killing other processes
200
- -k, --kill-others kill other processes if one exits or dies [boolean]
201
- --kill-others-on-fail kill other processes if one exits with non zero
202
- status code [boolean]
210
+ -k, --kill-others Kill other processes if one exits or dies.[boolean]
211
+ --kill-others-on-fail Kill other processes if one exits with non zero
212
+ status code. [boolean]
203
213
 
204
214
  Restarting
205
215
  --restart-tries How many times a process that died should restart.
@@ -212,6 +222,7 @@ Options:
212
222
  -h, --help Show help [boolean]
213
223
  -v, -V, --version Show version number [boolean]
214
224
 
225
+
215
226
  Examples:
216
227
 
217
228
  - Output nothing more than stdout+stderr of child processes
@@ -233,7 +244,8 @@ Examples:
233
244
 
234
245
  - Configuring via environment variables with CONCURRENTLY_ prefix
235
246
 
236
- $ CONCURRENTLY_RAW=true CONCURRENTLY_KILL_OTHERS=true concurrently "echo hello" "echo world"
247
+ $ CONCURRENTLY_RAW=true CONCURRENTLY_KILL_OTHERS=true concurrently "echo
248
+ hello" "echo world"
237
249
 
238
250
  - Send input to default
239
251
 
@@ -258,6 +270,23 @@ Examples:
258
270
 
259
271
  $ concurrently "npm:watch-*"
260
272
 
273
+ - Exclude patterns so that between "lint:js" and "lint:fix:js", only "lint:js"
274
+ is ran
275
+
276
+ $ concurrently "npm:*(!fix)"
277
+
278
+ - Passthrough some additional arguments via '{<number>}' placeholder
279
+
280
+ $ concurrently -P "echo {1}" -- foo
281
+
282
+ - Passthrough all additional arguments via '{@}' placeholder
283
+
284
+ $ concurrently -P "npm:dev-* -- {@}" -- --watch --noEmit
285
+
286
+ - Passthrough all additional arguments combined via '{*}' placeholder
287
+
288
+ $ concurrently -P "npm:dev-* -- {*}" -- --watch --noEmit
289
+
261
290
  For more details, visit https://github.com/open-cli-tools/concurrently
262
291
  ```
263
292
 
@@ -299,6 +328,7 @@ concurrently can be used programmatically by using the API documented below:
299
328
  - `restartDelay`: how many milliseconds to wait between process restarts. Default: `0`.
300
329
  - `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format)
301
330
  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.
302
332
 
303
333
  > **Returns:** an object in the shape `{ result, commands }`.
304
334
  > - `result`: a `Promise` that resolves if the run was successful (according to `successCondition` option),
@@ -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];
@@ -24,10 +28,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
28
  };
25
29
  Object.defineProperty(exports, "__esModule", { value: true });
26
30
  const yargs_1 = __importDefault(require("yargs"));
31
+ const helpers_1 = require("yargs/helpers");
27
32
  const defaults = __importStar(require("../src/defaults"));
28
33
  const index_1 = __importDefault(require("../src/index"));
29
34
  const epilogue_1 = require("./epilogue");
30
- const args = yargs_1.default
35
+ // Clean-up arguments (yargs expects only the arguments after the program name)
36
+ const cleanArgs = (0, helpers_1.hideBin)(process.argv);
37
+ // Find argument separator (double dash)
38
+ const argsSepIdx = cleanArgs.findIndex((arg) => arg === '--');
39
+ // Arguments before separator
40
+ const argsBeforeSep = argsSepIdx >= 0 ? cleanArgs.slice(0, argsSepIdx) : cleanArgs;
41
+ // Arguments after separator
42
+ const argsAfterSep = argsSepIdx >= 0 ? cleanArgs.slice(argsSepIdx + 1) : [];
43
+ const args = (0, yargs_1.default)(argsBeforeSep)
31
44
  .usage('$0 [options] <command ...>')
32
45
  .help('h')
33
46
  .alias('h', 'help')
@@ -42,13 +55,13 @@ const args = yargs_1.default
42
55
  alias: 'm',
43
56
  describe: 'How many processes should run at once.\n' +
44
57
  'New processes only spawn after all restart tries of a process.',
45
- type: 'number'
58
+ type: 'number',
46
59
  },
47
60
  'names': {
48
61
  alias: 'n',
49
62
  describe: 'List of custom names to be used in prefix template.\n' +
50
63
  'Example names: "main,browser,server"',
51
- type: 'string'
64
+ type: 'string',
52
65
  },
53
66
  'name-separator': {
54
67
  describe: 'The character to split <names> on. Example usage:\n' +
@@ -57,49 +70,61 @@ const args = yargs_1.default
57
70
  },
58
71
  'success': {
59
72
  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
73
+ describe: 'Which command(s) must exit with code 0 in order for concurrently exit with ' +
74
+ 'code 0 too. Options are:\n' +
75
+ '- "first" for the first command to exit;\n' +
76
+ '- "last" for the last command to exit;\n' +
77
+ '- "all" for all commands;\n' +
78
+ // Note: not a typo. Multiple commands can have the same name.
79
+ '- "command-{name}"/"command-{index}" for the commands with that name or index;\n' +
80
+ '- "!command-{name}"/"!command-{index}" for all commands but the ones with that ' +
81
+ 'name or index.\n',
82
+ default: defaults.success,
65
83
  },
66
84
  'raw': {
67
85
  alias: 'r',
68
86
  describe: 'Output only raw output of processes, disables prettifying ' +
69
87
  'and concurrently coloring.',
70
- type: 'boolean'
88
+ type: 'boolean',
71
89
  },
72
90
  // This one is provided for free. Chalk reads this itself and removes colours.
73
91
  // https://www.npmjs.com/package/chalk#chalksupportscolor
74
92
  'no-color': {
75
93
  describe: 'Disables colors from logging',
76
- type: 'boolean'
94
+ type: 'boolean',
77
95
  },
78
96
  'hide': {
79
97
  describe: 'Comma-separated list of processes to hide the output.\n' +
80
98
  'The processes can be identified by their name or index.',
81
99
  default: defaults.hide,
82
- type: 'string'
100
+ type: 'string',
83
101
  },
84
102
  'group': {
85
103
  alias: 'g',
86
104
  describe: 'Order the output as if the commands were run sequentially.',
87
- type: 'boolean'
105
+ type: 'boolean',
88
106
  },
89
107
  'timings': {
90
- describe: 'Show timing information for all processes',
108
+ describe: 'Show timing information for all processes.',
109
+ type: 'boolean',
110
+ default: defaults.timings,
111
+ },
112
+ 'passthrough-arguments': {
113
+ alias: 'P',
114
+ describe: 'Passthrough additional arguments to commands (accessible via placeholders) ' +
115
+ 'instead of treating them as commands.',
91
116
  type: 'boolean',
92
- default: defaults.timings
117
+ default: defaults.passthroughArguments,
93
118
  },
94
119
  // Kill others
95
120
  'kill-others': {
96
121
  alias: 'k',
97
- describe: 'kill other processes if one exits or dies',
98
- type: 'boolean'
122
+ describe: 'Kill other processes if one exits or dies.',
123
+ type: 'boolean',
99
124
  },
100
125
  'kill-others-on-fail': {
101
- describe: 'kill other processes if one exits with non zero status code',
102
- type: 'boolean'
126
+ describe: 'Kill other processes if one exits with non zero status code.',
127
+ type: 'boolean',
103
128
  },
104
129
  // Prefix
105
130
  'prefix': {
@@ -108,7 +133,7 @@ const args = yargs_1.default
108
133
  'Possible values: index, pid, time, command, name, none, or a template. ' +
109
134
  'Example template: "{time}-{pid}"',
110
135
  defaultDescription: 'index or name (when --names is set)',
111
- type: 'string'
136
+ type: 'string',
112
137
  },
113
138
  'prefix-colors': {
114
139
  alias: 'c',
@@ -120,74 +145,78 @@ const args = yargs_1.default
120
145
  '- Available background colors: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite\n' +
121
146
  'See https://www.npmjs.com/package/chalk for more information.',
122
147
  default: defaults.prefixColors,
123
- type: 'string'
148
+ type: 'string',
124
149
  },
125
150
  'prefix-length': {
126
151
  alias: 'l',
127
152
  describe: 'Limit how many characters of the command is displayed in prefix. ' +
128
153
  'The option can be used to shorten the prefix when it is set to "command"',
129
154
  default: defaults.prefixLength,
130
- type: 'number'
155
+ type: 'number',
131
156
  },
132
157
  'timestamp-format': {
133
158
  alias: 't',
134
159
  describe: 'Specify the timestamp in moment/date-fns format.',
135
160
  default: defaults.timestampFormat,
136
- type: 'string'
161
+ type: 'string',
137
162
  },
138
163
  // Restarting
139
164
  'restart-tries': {
140
165
  describe: 'How many times a process that died should restart.\n' +
141
166
  'Negative numbers will make the process restart forever.',
142
167
  default: defaults.restartTries,
143
- type: 'number'
168
+ type: 'number',
144
169
  },
145
170
  'restart-after': {
146
171
  describe: 'Delay time to respawn the process, in milliseconds.',
147
172
  default: defaults.restartDelay,
148
- type: 'number'
173
+ type: 'number',
149
174
  },
150
175
  // Input
151
176
  'handle-input': {
152
177
  alias: 'i',
153
178
  describe: 'Whether input should be forwarded to the child processes. ' +
154
179
  'See examples for more information.',
155
- type: 'boolean'
180
+ type: 'boolean',
156
181
  },
157
182
  'default-input-target': {
158
183
  default: defaults.defaultInputTarget,
159
184
  describe: 'Identifier for child process to which input on stdin ' +
160
185
  'should be sent if not specified at start of input.\n' +
161
- 'Can be either the index or the name of the process.'
162
- }
186
+ 'Can be either the index or the name of the process.',
187
+ },
163
188
  })
164
- .group(['m', 'n', 'name-separator', 'raw', 's', 'no-color', 'hide', 'group', 'timings'], 'General')
189
+ .group(['m', 'n', 'name-separator', 's', 'r', 'no-color', 'hide', 'g', 'timings', 'P'], 'General')
165
190
  .group(['p', 'c', 'l', 't'], 'Prefix styling')
166
191
  .group(['i', 'default-input-target'], 'Input handling')
167
192
  .group(['k', 'kill-others-on-fail'], 'Killing other processes')
168
193
  .group(['restart-tries', 'restart-after'], 'Restarting')
169
194
  .epilogue(epilogue_1.epilogue)
170
- .argv;
171
- const names = (args.names || '').split(args['name-separator']);
172
- (0, index_1.default)(args._.map((command, index) => ({
195
+ .parseSync();
196
+ // Get names of commands by the specified separator
197
+ const names = (args.names || '').split(args.nameSeparator);
198
+ // If "passthrough-arguments" is disabled, treat additional arguments as commands
199
+ const commands = args.passthroughArguments ? args._ : [...args._, ...argsAfterSep];
200
+ (0, index_1.default)(commands.map((command, index) => ({
173
201
  command: String(command),
174
- name: names[index]
202
+ name: names[index],
175
203
  })), {
176
- handleInput: args['handle-input'],
177
- defaultInputTarget: args['default-input-target'],
204
+ handleInput: args.handleInput,
205
+ defaultInputTarget: args.defaultInputTarget,
178
206
  killOthers: args.killOthers
179
207
  ? ['success', 'failure']
180
208
  : (args.killOthersOnFail ? ['failure'] : []),
181
- maxProcesses: args['max-processes'],
209
+ maxProcesses: args.maxProcesses,
182
210
  raw: args.raw,
183
211
  hide: args.hide.split(','),
184
212
  group: args.group,
185
213
  prefix: args.prefix,
186
- prefixColors: args['prefix-colors'].split(','),
187
- prefixLength: args['prefix-length'],
188
- restartDelay: args['restart-after'],
189
- restartTries: args['restart-tries'],
214
+ prefixColors: args.prefixColors.split(','),
215
+ prefixLength: args.prefixLength,
216
+ restartDelay: args.restartAfter,
217
+ restartTries: args.restartTries,
190
218
  successCondition: args.success,
191
- timestampFormat: args['timestamp-format'],
192
- timings: args.timings
219
+ timestampFormat: args.timestampFormat,
220
+ timings: args.timings,
221
+ additionalArguments: args.passthroughArguments ? argsAfterSep : undefined,
193
222
  }).result.then(() => process.exit(0), () => process.exit(1));
@@ -6,11 +6,11 @@ exports.epilogue = void 0;
6
6
  const examples = [
7
7
  {
8
8
  description: 'Output nothing more than stdout+stderr of child processes',
9
- example: '$ $0 --raw "npm run watch-less" "npm run watch-js"'
9
+ example: '$ $0 --raw "npm run watch-less" "npm run watch-js"',
10
10
  },
11
11
  {
12
12
  description: 'Normal output but without colors e.g. when logging to file',
13
- example: '$ $0 --no-color "grunt watch" "http-server" > log'
13
+ example: '$ $0 --no-color "grunt watch" "http-server" > log',
14
14
  },
15
15
  {
16
16
  description: 'Custom prefix',
@@ -28,21 +28,21 @@ const examples = [
28
28
  description: 'Send input to default',
29
29
  example: [
30
30
  '$ $0 --handle-input "nodemon" "npm run watch-js"',
31
- 'rs # Sends rs command to nodemon process'
31
+ 'rs # Sends rs command to nodemon process',
32
32
  ].join('\n'),
33
33
  },
34
34
  {
35
35
  description: 'Send input to specific child identified by index',
36
36
  example: [
37
37
  '$ $0 --handle-input "npm run watch-js" nodemon',
38
- '1:rs'
38
+ '1:rs',
39
39
  ].join('\n'),
40
40
  },
41
41
  {
42
42
  description: 'Send input to specific child identified by name',
43
43
  example: [
44
44
  '$ $0 --handle-input -n js,srv "npm run watch-js" nodemon',
45
- 'srv:rs'
45
+ 'srv:rs',
46
46
  ].join('\n'),
47
47
  },
48
48
  {
@@ -55,8 +55,20 @@ const examples = [
55
55
  },
56
56
  {
57
57
  description: 'Exclude patterns so that between "lint:js" and "lint:fix:js", only "lint:js" is ran',
58
- example: '$ $0 "npm:*(!fix)"'
59
- }
58
+ example: '$ $0 "npm:*(!fix)"',
59
+ },
60
+ {
61
+ description: 'Passthrough some additional arguments via \'{<number>}\' placeholder',
62
+ example: '$ $0 -P "echo {1}" -- foo',
63
+ },
64
+ {
65
+ description: 'Passthrough all additional arguments via \'{@}\' placeholder',
66
+ example: '$ $0 -P "npm:dev-* -- {@}" -- --watch --noEmit',
67
+ },
68
+ {
69
+ description: 'Passthrough all additional arguments combined via \'{*}\' placeholder',
70
+ example: '$ $0 -P "npm:dev-* -- {*}" -- --watch --noEmit',
71
+ },
60
72
  ];
61
73
  exports.epilogue = `
62
74
  Examples:
@@ -0,0 +1,12 @@
1
+ import { CommandInfo } from '../command';
2
+ import { CommandParser } from './command-parser';
3
+ /**
4
+ * Replace placeholders with additional arguments.
5
+ */
6
+ export declare class ExpandArguments implements CommandParser {
7
+ private readonly additionalArguments;
8
+ constructor(additionalArguments: string[]);
9
+ parse(commandInfo: CommandInfo): CommandInfo & {
10
+ command: string;
11
+ };
12
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpandArguments = void 0;
4
+ const shell_quote_1 = require("shell-quote");
5
+ /**
6
+ * Replace placeholders with additional arguments.
7
+ */
8
+ class ExpandArguments {
9
+ constructor(additionalArguments) {
10
+ this.additionalArguments = additionalArguments;
11
+ }
12
+ parse(commandInfo) {
13
+ const command = commandInfo.command.replace(/\\?\{([@\*]|[1-9][0-9]*)\}/g, (match, placeholderTarget) => {
14
+ // Don't replace the placeholder if it is escaped by a backslash.
15
+ if (match.startsWith('\\')) {
16
+ return match.substring(1);
17
+ }
18
+ // Replace numeric placeholder if value exists in additional arguments.
19
+ if (!isNaN(placeholderTarget) &&
20
+ placeholderTarget <= this.additionalArguments.length) {
21
+ return (0, shell_quote_1.quote)([this.additionalArguments[placeholderTarget - 1]]);
22
+ }
23
+ // Replace all arguments placeholder.
24
+ if (placeholderTarget === '@') {
25
+ return (0, shell_quote_1.quote)(this.additionalArguments);
26
+ }
27
+ // Replace combined arguments placeholder.
28
+ if (placeholderTarget === '*') {
29
+ return (0, shell_quote_1.quote)([this.additionalArguments.join(' ')]);
30
+ }
31
+ // Replace placeholder with empty string
32
+ // if value doesn't exist in additional arguments.
33
+ return '';
34
+ });
35
+ return Object.assign({}, commandInfo, {
36
+ command,
37
+ });
38
+ }
39
+ }
40
+ exports.ExpandArguments = ExpandArguments;
@@ -12,7 +12,7 @@ class ExpandNpmShortcut {
12
12
  }
13
13
  return Object.assign({}, commandInfo, {
14
14
  name: commandInfo.name || cmdName,
15
- command: `${npmCmd} run ${cmdName}${args}`
15
+ command: `${npmCmd} run ${cmdName}${args}`,
16
16
  });
17
17
  }
18
18
  }
@@ -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];
@@ -9,7 +9,7 @@ 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.substr(1, command.length - 2);
12
+ command = command.substring(1, command.length - 1);
13
13
  }
14
14
  return Object.assign({}, commandInfo, { command });
15
15
  }
@@ -23,6 +23,9 @@ export interface CommandInfo {
23
23
  * The current working directory of the process when spawned.
24
24
  */
25
25
  cwd?: string;
26
+ /**
27
+ * Color to use on prefix of command.
28
+ */
26
29
  prefixColor?: string;
27
30
  }
28
31
  export interface 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];
@@ -74,7 +78,7 @@ class Command {
74
78
  startDate,
75
79
  endDate,
76
80
  durationSeconds: durationSeconds + (durationNanoSeconds / 1e9),
77
- }
81
+ },
78
82
  });
79
83
  });
80
84
  child.stdout && pipeTo(Rx.fromEvent(child.stdout, 'data'), this.stdout);
@@ -6,8 +6,10 @@ import { CloseEvent, Command } from './command';
6
6
  * - `first`: only the first specified command;
7
7
  * - `last`: only the last specified command;
8
8
  * - `all`: all commands.
9
+ * - `command-{name|index}`: only the commands with the specified names or index.
10
+ * - `!command-{name|index}`: all commands but the ones with the specified names or index.
9
11
  */
10
- export declare type SuccessCondition = 'first' | 'last' | 'all';
12
+ export declare type SuccessCondition = 'first' | 'last' | 'all' | `command-${string | number}` | `!command-${string | number}`;
11
13
  /**
12
14
  * Provides logic to determine whether lists of commands ran successfully.
13
15
  */
@@ -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];
@@ -30,17 +34,32 @@ class CompletionListener {
30
34
  this.successCondition = successCondition;
31
35
  this.scheduler = scheduler;
32
36
  }
33
- isSuccess(exitCodes) {
34
- switch (this.successCondition) {
35
- /* eslint-disable indent */
36
- case 'first':
37
- return exitCodes[0] === 0;
38
- case 'last':
39
- return exitCodes[exitCodes.length - 1] === 0;
40
- default:
41
- return exitCodes.every(exitCode => exitCode === 0);
42
- /* eslint-enable indent */
37
+ isSuccess(events) {
38
+ if (this.successCondition === 'first') {
39
+ return events[0].exitCode === 0;
40
+ }
41
+ else if (this.successCondition === 'last') {
42
+ return events[events.length - 1].exitCode === 0;
43
+ }
44
+ const commandSyntaxMatch = this.successCondition.match(/^!?command-(.+)$/);
45
+ if (commandSyntaxMatch == null) {
46
+ // If not a `command-` syntax, then it's an 'all' condition or it's treated as such.
47
+ return events.every(({ exitCode }) => exitCode === 0);
48
+ }
49
+ // Check `command-` syntax condition.
50
+ // Note that a command's `name` is not necessarily unique,
51
+ // in which case all of them must meet the success condition.
52
+ const nameOrIndex = commandSyntaxMatch[1];
53
+ const targetCommandsEvents = events.filter(({ command, index }) => (command.name === nameOrIndex
54
+ || index === Number(nameOrIndex)));
55
+ if (this.successCondition.startsWith('!')) {
56
+ // All commands except the specified ones must exit succesfully
57
+ return events.every((event) => (targetCommandsEvents.includes(event)
58
+ || event.exitCode === 0));
43
59
  }
60
+ // Only the specified commands must exit succesfully
61
+ return targetCommandsEvents.length > 0
62
+ && targetCommandsEvents.every(event => event.exitCode === 0);
44
63
  }
45
64
  /**
46
65
  * Given a list of commands, wait for all of them to exit and then evaluate their exit codes.
@@ -49,11 +68,10 @@ class CompletionListener {
49
68
  */
50
69
  listen(commands) {
51
70
  const closeStreams = commands.map(command => command.close);
52
- return Rx.merge(...closeStreams)
53
- .pipe((0, operators_1.bufferCount)(closeStreams.length), (0, operators_1.switchMap)(exitInfos => this.isSuccess(exitInfos.map(({ exitCode }) => exitCode))
71
+ return Rx.lastValueFrom(Rx.merge(...closeStreams)
72
+ .pipe((0, operators_1.bufferCount)(closeStreams.length), (0, operators_1.switchMap)(exitInfos => this.isSuccess(exitInfos)
54
73
  ? Rx.of(exitInfos, this.scheduler)
55
- : Rx.throwError(exitInfos, this.scheduler)), (0, operators_1.take)(1))
56
- .toPromise();
74
+ : Rx.throwError(exitInfos, this.scheduler)), (0, operators_1.take)(1)));
57
75
  }
58
76
  }
59
77
  exports.CompletionListener = CompletionListener;
@@ -29,7 +29,13 @@ export declare type ConcurrentlyOptions = {
29
29
  * Which stream should the commands output be written to.
30
30
  */
31
31
  outputStream?: Writable;
32
+ /**
33
+ * Whether the output should be ordered as if the commands were run sequentially.
34
+ */
32
35
  group?: boolean;
36
+ /**
37
+ * Comma-separated list of chalk colors to use on prefixes.
38
+ */
33
39
  prefixColors?: string[];
34
40
  /**
35
41
  * Maximum number of commands to run at once.
@@ -67,6 +73,13 @@ export declare type ConcurrentlyOptions = {
67
73
  * Defaults to the `tree-kill` module.
68
74
  */
69
75
  kill: KillProcess;
76
+ /**
77
+ * List of additional arguments passed that will get replaced in each command.
78
+ * If not defined, no argument replacing will happen.
79
+ *
80
+ * @see ExpandArguments
81
+ */
82
+ additionalArguments?: string[];
70
83
  };
71
84
  /**
72
85
  * Core concurrently functionality -- spawns the given commands concurrently and
@@ -9,6 +9,7 @@ const lodash_1 = __importDefault(require("lodash"));
9
9
  const spawn_command_1 = __importDefault(require("spawn-command"));
10
10
  const tree_kill_1 = __importDefault(require("tree-kill"));
11
11
  const command_1 = require("./command");
12
+ const expand_arguments_1 = require("./command-parser/expand-arguments");
12
13
  const expand_npm_shortcut_1 = require("./command-parser/expand-npm-shortcut");
13
14
  const expand_npm_wildcard_1 = require("./command-parser/expand-npm-wildcard");
14
15
  const strip_quotes_1 = require("./command-parser/strip-quotes");
@@ -35,8 +36,11 @@ function concurrently(baseCommands, baseOptions) {
35
36
  const commandParsers = [
36
37
  new strip_quotes_1.StripQuotes(),
37
38
  new expand_npm_shortcut_1.ExpandNpmShortcut(),
38
- new expand_npm_wildcard_1.ExpandNpmWildcard()
39
+ new expand_npm_wildcard_1.ExpandNpmWildcard(),
39
40
  ];
41
+ if (options.additionalArguments) {
42
+ commandParsers.push(new expand_arguments_1.ExpandArguments(options.additionalArguments));
43
+ }
40
44
  let lastColor = '';
41
45
  let commands = (0, lodash_1.default)(baseCommands)
42
46
  .map(mapToCommandInfo)
@@ -58,7 +62,7 @@ function concurrently(baseCommands, baseOptions) {
58
62
  const { commands, onFinish } = controller.handle(prevCommands);
59
63
  return {
60
64
  commands,
61
- onFinishCallbacks: lodash_1.default.concat(onFinishCallbacks, onFinish ? [onFinish] : [])
65
+ onFinishCallbacks: lodash_1.default.concat(onFinishCallbacks, onFinish ? [onFinish] : []),
62
66
  };
63
67
  }, { commands, onFinishCallbacks: [] });
64
68
  commands = handleResult.commands;
@@ -1,14 +1,20 @@
1
1
  import { SuccessCondition } from './completion-listener';
2
2
  export declare const defaultInputTarget = 0;
3
3
  /**
4
- * Whether process.stdin should be forwarded to child processes
4
+ * Whether process.stdin should be forwarded to child processes.
5
5
  */
6
6
  export declare const handleInput = false;
7
7
  /**
8
8
  * How many processes to run at once.
9
9
  */
10
10
  export declare const maxProcesses = 0;
11
+ /**
12
+ * Indices and names of commands whose output are not to be logged.
13
+ */
11
14
  export declare const hide = "";
15
+ /**
16
+ * The character to split <names> on.
17
+ */
12
18
  export declare const nameSeparator = ",";
13
19
  /**
14
20
  * Which prefix style to use when logging processes output.
@@ -20,12 +26,12 @@ export declare const prefix = "";
20
26
  */
21
27
  export declare const prefixColors = "reset";
22
28
  /**
23
- * How many bytes we'll show on the command prefix
29
+ * How many bytes we'll show on the command prefix.
24
30
  */
25
31
  export declare const prefixLength = 10;
26
32
  export declare const raw = false;
27
33
  /**
28
- * Number of attempts of restarting a process, if it exits with non-0 code
34
+ * Number of attempts of restarting a process, if it exits with non-0 code.
29
35
  */
30
36
  export declare const restartTries = 0;
31
37
  /**
@@ -47,6 +53,10 @@ export declare const timestampFormat = "yyyy-MM-dd HH:mm:ss.SSS";
47
53
  */
48
54
  export declare const cwd: string | undefined;
49
55
  /**
50
- * Whether to show timing information for processes in console output
56
+ * Whether to show timing information for processes in console output.
51
57
  */
52
58
  export declare const timings = false;
59
+ /**
60
+ * Passthrough additional arguments to commands (accessible via placeholders) instead of treating them as commands.
61
+ */
62
+ export declare const passthroughArguments = false;
@@ -3,18 +3,23 @@
3
3
  // It's read by the flow controllers, the executable, etc.
4
4
  // Refer to tests for the meaning of the different possible values.
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.timings = exports.cwd = exports.timestampFormat = exports.success = exports.restartDelay = exports.restartTries = exports.raw = exports.prefixLength = exports.prefixColors = exports.prefix = exports.nameSeparator = exports.hide = exports.maxProcesses = exports.handleInput = exports.defaultInputTarget = void 0;
6
+ exports.passthroughArguments = exports.timings = exports.cwd = exports.timestampFormat = exports.success = exports.restartDelay = exports.restartTries = exports.raw = exports.prefixLength = exports.prefixColors = exports.prefix = exports.nameSeparator = exports.hide = exports.maxProcesses = exports.handleInput = exports.defaultInputTarget = void 0;
7
7
  exports.defaultInputTarget = 0;
8
8
  /**
9
- * Whether process.stdin should be forwarded to child processes
9
+ * Whether process.stdin should be forwarded to child processes.
10
10
  */
11
11
  exports.handleInput = false;
12
12
  /**
13
13
  * How many processes to run at once.
14
14
  */
15
15
  exports.maxProcesses = 0;
16
- // Indices and names of commands whose output are not to be logged
16
+ /**
17
+ * Indices and names of commands whose output are not to be logged.
18
+ */
17
19
  exports.hide = '';
20
+ /**
21
+ * The character to split <names> on.
22
+ */
18
23
  exports.nameSeparator = ',';
19
24
  /**
20
25
  * Which prefix style to use when logging processes output.
@@ -26,12 +31,12 @@ exports.prefix = '';
26
31
  */
27
32
  exports.prefixColors = 'reset';
28
33
  /**
29
- * How many bytes we'll show on the command prefix
34
+ * How many bytes we'll show on the command prefix.
30
35
  */
31
36
  exports.prefixLength = 10;
32
37
  exports.raw = false;
33
38
  /**
34
- * Number of attempts of restarting a process, if it exits with non-0 code
39
+ * Number of attempts of restarting a process, if it exits with non-0 code.
35
40
  */
36
41
  exports.restartTries = 0;
37
42
  /**
@@ -53,6 +58,10 @@ exports.timestampFormat = 'yyyy-MM-dd HH:mm:ss.SSS';
53
58
  */
54
59
  exports.cwd = undefined;
55
60
  /**
56
- * Whether to show timing information for processes in console output
61
+ * Whether to show timing information for processes in console output.
57
62
  */
58
63
  exports.timings = false;
64
+ /**
65
+ * Passthrough additional arguments to commands (accessible via placeholders) instead of treating them as commands.
66
+ */
67
+ exports.passthroughArguments = false;
@@ -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];
@@ -27,9 +27,9 @@ class KillOnSignal {
27
27
  return new Proxy(command, {
28
28
  get(target, prop) {
29
29
  return prop === 'close' ? closeStream : target[prop];
30
- }
30
+ },
31
31
  });
32
- })
32
+ }),
33
33
  };
34
34
  }
35
35
  }
@@ -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];
@@ -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];
@@ -61,9 +65,9 @@ class RestartProcess {
61
65
  return new Proxy(command, {
62
66
  get(target, prop) {
63
67
  return prop === 'close' ? closeStream : target[prop];
64
- }
68
+ },
65
69
  });
66
- })
70
+ }),
67
71
  };
68
72
  }
69
73
  }
@@ -63,6 +63,11 @@ export declare type ConcurrentlyOptions = BaseConcurrentlyOptions & {
63
63
  * @see LogTimings
64
64
  */
65
65
  timings?: boolean;
66
+ /**
67
+ * List of additional arguments passed that will get replaced in each command.
68
+ * If not defined, no argument replacing will happen.
69
+ */
70
+ additionalArguments?: string[];
66
71
  };
67
72
  declare const _default: (commands: ConcurrentlyCommandInput[], options?: Partial<ConcurrentlyOptions>) => ConcurrentlyResult;
68
73
  export default _default;
package/dist/src/index.js CHANGED
@@ -57,13 +57,14 @@ exports.default = (commands, options = {}) => {
57
57
  }),
58
58
  new kill_others_1.KillOthers({
59
59
  logger,
60
- conditions: options.killOthers
60
+ conditions: options.killOthers,
61
61
  }),
62
62
  new log_timings_1.LogTimings({
63
63
  logger: options.timings ? logger : null,
64
64
  timestampFormat: options.timestampFormat,
65
- })
65
+ }),
66
66
  ],
67
67
  prefixColors: options.prefixColors || [],
68
+ additionalArguments: options.additionalArguments,
68
69
  });
69
70
  };
@@ -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];
@@ -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];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "concurrently",
3
- "version": "7.1.0",
3
+ "version": "7.2.2",
4
4
  "description": "Run commands concurrently",
5
5
  "main": "index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -14,7 +14,8 @@
14
14
  "exports": {
15
15
  "import": "./index.mjs",
16
16
  "require": "./index.js",
17
- "default": "./index.js"
17
+ "default": "./index.js",
18
+ "types": "./dist/src/index.d.ts"
18
19
  },
19
20
  "scripts": {
20
21
  "build": "tsc --build",
@@ -43,24 +44,27 @@
43
44
  "chalk": "^4.1.0",
44
45
  "date-fns": "^2.16.1",
45
46
  "lodash": "^4.17.21",
46
- "rxjs": "^6.6.3",
47
+ "rxjs": "^7.0.0",
48
+ "shell-quote": "^1.7.3",
47
49
  "spawn-command": "^0.0.2-1",
48
50
  "supports-color": "^8.1.0",
49
51
  "tree-kill": "^1.2.2",
50
- "yargs": "^16.2.0"
52
+ "yargs": "^17.3.1"
51
53
  },
52
54
  "devDependencies": {
53
55
  "@types/jest": "^27.0.3",
54
56
  "@types/lodash": "^4.14.178",
55
57
  "@types/node": "^17.0.0",
58
+ "@types/shell-quote": "^1.7.1",
56
59
  "@types/supports-color": "^8.1.1",
60
+ "@types/yargs": "^17.0.8",
57
61
  "@typescript-eslint/eslint-plugin": "^5.8.1",
58
62
  "@typescript-eslint/parser": "^5.8.1",
59
- "coveralls": "^3.1.0",
60
- "eslint": "^7.17.0",
61
- "jest": "^26.6.3",
62
- "jest-create-mock-instance": "^1.1.0",
63
- "ts-jest": "^26.5.6",
63
+ "coveralls-next": "^4.1.2",
64
+ "eslint": "^8.15.0",
65
+ "jest": "^27.5.1",
66
+ "jest-create-mock-instance": "^2.0.0",
67
+ "ts-jest": "^27.1.4",
64
68
  "ts-node": "^10.4.0",
65
69
  "typescript": "^4.5.4"
66
70
  },