concurrently 8.2.1 → 9.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 (63) hide show
  1. package/README.md +35 -240
  2. package/dist/bin/concurrently.js +37 -22
  3. package/dist/bin/read-package.d.ts +6 -0
  4. package/dist/bin/read-package.js +47 -0
  5. package/dist/src/command-parser/expand-arguments.d.ts +1 -0
  6. package/dist/src/command-parser/expand-arguments.js +1 -0
  7. package/dist/src/command-parser/expand-npm-shortcut.d.ts +1 -1
  8. package/dist/src/command-parser/expand-npm-shortcut.js +4 -3
  9. package/dist/src/command-parser/expand-npm-wildcard.js +4 -2
  10. package/dist/src/command-parser/strip-quotes.d.ts +1 -0
  11. package/dist/src/command.d.ts +46 -5
  12. package/dist/src/command.js +91 -16
  13. package/dist/src/completion-listener.d.ts +4 -1
  14. package/dist/src/completion-listener.js +27 -6
  15. package/dist/src/concurrently.d.ts +30 -5
  16. package/dist/src/concurrently.js +15 -14
  17. package/dist/src/date-format.d.ts +19 -0
  18. package/dist/src/date-format.js +318 -0
  19. package/dist/src/defaults.d.ts +1 -1
  20. package/dist/src/defaults.js +1 -1
  21. package/dist/src/flow-control/flow-controller.d.ts +1 -1
  22. package/dist/src/flow-control/input-handler.js +4 -0
  23. package/dist/src/flow-control/kill-on-signal.d.ts +4 -1
  24. package/dist/src/flow-control/kill-on-signal.js +8 -1
  25. package/dist/src/flow-control/kill-others.d.ts +4 -1
  26. package/dist/src/flow-control/kill-others.js +7 -1
  27. package/dist/src/flow-control/log-error.js +1 -0
  28. package/dist/src/flow-control/log-exit.js +1 -0
  29. package/dist/src/flow-control/log-output.js +1 -0
  30. package/dist/src/flow-control/log-timings.d.ts +1 -1
  31. package/dist/src/flow-control/log-timings.js +6 -4
  32. package/dist/src/flow-control/logger-padding.d.ts +13 -0
  33. package/dist/src/flow-control/logger-padding.js +35 -0
  34. package/dist/src/flow-control/restart-process.d.ts +3 -2
  35. package/dist/src/flow-control/restart-process.js +14 -2
  36. package/dist/src/flow-control/teardown.d.ts +21 -0
  37. package/dist/src/flow-control/teardown.js +72 -0
  38. package/dist/src/index.d.ts +18 -8
  39. package/dist/src/index.js +28 -7
  40. package/dist/src/logger.d.ts +25 -10
  41. package/dist/src/logger.js +78 -39
  42. package/dist/src/output-writer.js +6 -2
  43. package/dist/src/prefix-color-selector.d.ts +1 -1
  44. package/dist/src/prefix-color-selector.js +3 -1
  45. package/dist/src/{get-spawn-opts.d.ts → spawn.d.ts} +20 -5
  46. package/dist/src/spawn.js +49 -0
  47. package/docs/README.md +13 -0
  48. package/docs/cli/configuration.md +11 -0
  49. package/docs/cli/input-handling.md +40 -0
  50. package/docs/cli/output-control.md +35 -0
  51. package/docs/cli/passthrough-arguments.md +80 -0
  52. package/docs/cli/prefixing.md +147 -0
  53. package/docs/cli/restarting.md +38 -0
  54. package/docs/cli/shortcuts.md +72 -0
  55. package/docs/demo.gif +0 -0
  56. package/index.d.mts +7 -0
  57. package/index.d.ts +11 -0
  58. package/index.js +6 -1
  59. package/index.mjs +2 -2
  60. package/package.json +41 -33
  61. package/dist/bin/epilogue.d.ts +0 -1
  62. package/dist/bin/epilogue.js +0 -90
  63. package/dist/src/get-spawn-opts.js +0 -18
package/README.md CHANGED
@@ -39,7 +39,6 @@ tired of opening terminals and made **concurrently**.
39
39
  - Cross platform (including Windows)
40
40
  - Output is easy to follow with prefixes
41
41
  - With `--kill-others` switch, all commands are killed if one dies
42
- - Spawns commands with [spawn-command](https://github.com/mmalecki/spawn-command)
43
42
 
44
43
  ## Installation
45
44
 
@@ -55,7 +54,7 @@ tired of opening terminals and made **concurrently**.
55
54
  ## Usage
56
55
 
57
56
  > **Note**
58
- > The `concurrently` command is now also available under the shorthand alias `conc`.
57
+ > The `concurrently` command is also available under the shorthand alias `conc`.
59
58
 
60
59
  The tool is written in Node.js, but you can use it to run **any** commands.
61
60
 
@@ -74,240 +73,10 @@ In package.json, escape quotes:
74
73
  "start": "concurrently \"command1 arg\" \"command2 arg\""
75
74
  ```
76
75
 
77
- NPM run commands can be shortened:
76
+ You can always check concurrently's flag list by running `concurrently --help`.
77
+ For the version, run `concurrently --version`.
78
78
 
79
- ```bash
80
- concurrently "npm:watch-js" "npm:watch-css" "npm:watch-node"
81
-
82
- # Equivalent to:
83
- concurrently -n watch-js,watch-css,watch-node "npm run watch-js" "npm run watch-css" "npm run watch-node"
84
- ```
85
-
86
- NPM shortened commands also support wildcards. Given the following scripts in
87
- package.json:
88
-
89
- ```jsonc
90
- {
91
- //...
92
- "scripts": {
93
- // ...
94
- "watch-js": "...",
95
- "watch-css": "...",
96
- "watch-node": "..."
97
- // ...
98
- }
99
- // ...
100
- }
101
- ```
102
-
103
- ```bash
104
- concurrently "npm:watch-*"
105
-
106
- # Equivalent to:
107
- concurrently -n js,css,node "npm run watch-js" "npm run watch-css" "npm run watch-node"
108
-
109
- # Any name provided for the wildcard command will be used as a prefix to the wildcard
110
- # part of the script name:
111
- concurrently -n w: npm:watch-*
112
-
113
- # Equivalent to:
114
- concurrently -n w:js,w:css,w:node "npm run watch-js" "npm run watch-css" "npm run watch-node"
115
- ```
116
-
117
- Exclusion is also supported. Given the following scripts in package.json:
118
-
119
- ```jsonc
120
- {
121
- // ...
122
- "scripts": {
123
- "lint:js": "...",
124
- "lint:ts": "...",
125
- "lint:fix:js": "...",
126
- "lint:fix:ts": "..."
127
- // ...
128
- }
129
- // ...
130
- }
131
- ```
132
-
133
- ```bash
134
- # Running only lint:js and lint:ts
135
- # with lint:fix:js and lint:fix:ts excluded
136
- concurrently "npm:lint:*(!fix)"
137
- ```
138
-
139
- Good frontend one-liner example [here](https://github.com/kimmobrunfeldt/dont-copy-paste-this-frontend-template/blob/5cd2bde719654941bdfc0a42c6f1b8e69ae79980/package.json#L9).
140
-
141
- Help:
142
-
143
- ```
144
- concurrently [options] <command ...>
145
-
146
- General
147
- -m, --max-processes How many processes should run at once.
148
- Exact number or a percent of CPUs available (for example "50%").
149
- New processes only spawn after all restart tries
150
- of a process. [string]
151
- -n, --names List of custom names to be used in prefix
152
- template.
153
- Example names: "main,browser,server" [string]
154
- --name-separator The character to split <names> on. Example usage:
155
- -n "styles|scripts|server" --name-separator "|"
156
- [default: ","]
157
- -s, --success Which command(s) must exit with code 0 in order
158
- for concurrently exit with code 0 too. Options
159
- are:
160
- - "first" for the first command to exit;
161
- - "last" for the last command to exit;
162
- - "all" for all commands;
163
- - "command-{name}"/"command-{index}" for the
164
- commands with that name or index;
165
- - "!command-{name}"/"!command-{index}" for all
166
- commands but the ones with that name or index.
167
- [default: "all"]
168
- -r, --raw Output only raw output of processes, disables
169
- prettifying and concurrently coloring. [boolean]
170
- --no-color Disables colors from logging [boolean]
171
- --hide Comma-separated list of processes to hide the
172
- output.
173
- The processes can be identified by their name or
174
- index. [string] [default: ""]
175
- -g, --group Order the output as if the commands were run
176
- sequentially. [boolean]
177
- --timings Show timing information for all processes.
178
- [boolean] [default: false]
179
- -P, --passthrough-arguments Passthrough additional arguments to commands
180
- (accessible via placeholders) instead of treating
181
- them as commands. [boolean] [default: false]
182
-
183
- Prefix styling
184
- -p, --prefix Prefix used in logging for each process.
185
- Possible values: index, pid, time, command, name,
186
- none, or a template. Example template: "{time}-{pid}"
187
- [string] [default: index or name (when --names is set)]
188
- -c, --prefix-colors Comma-separated list of chalk colors to use on
189
- prefixes. If there are more commands than colors, the
190
- last color will be repeated.
191
- - Available modifiers: reset, bold, dim, italic,
192
- underline, inverse, hidden, strikethrough
193
- - Available colors: black, red, green, yellow, blue,
194
- magenta, cyan, white, gray,
195
- any hex values for colors (e.g. #23de43) or auto for
196
- an automatically picked color
197
- - Available background colors: bgBlack, bgRed,
198
- bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite
199
- See https://www.npmjs.com/package/chalk for more
200
- information. [string] [default: "reset"]
201
- -l, --prefix-length Limit how many characters of the command is displayed
202
- in prefix. The option can be used to shorten the
203
- prefix when it is set to "command"
204
- [number] [default: 10]
205
- -t, --timestamp-format Specify the timestamp in moment/date-fns format.
206
- [string] [default: "yyyy-MM-dd HH:mm:ss.SSS"]
207
-
208
- Input handling
209
- -i, --handle-input Whether input should be forwarded to the child
210
- processes. See examples for more information.
211
- [boolean]
212
- --default-input-target Identifier for child process to which input on
213
- stdin should be sent if not specified at start of
214
- input.
215
- Can be either the index or the name of the
216
- process. [default: 0]
217
-
218
- Killing other processes
219
- -k, --kill-others Kill other processes if one exits or dies.[boolean]
220
- --kill-others-on-fail Kill other processes if one exits with non zero
221
- status code. [boolean]
222
- --kill-signal Signal to send to other processes if one exits or dies.
223
- (SIGTERM/SIGKILL, defaults to SIGTERM) [string]
224
-
225
- Restarting
226
- --restart-tries How many times a process that died should restart.
227
- Negative numbers will make the process restart forever.
228
- [number] [default: 0]
229
- --restart-after Delay time to respawn the process, in milliseconds.
230
- [number] [default: 0]
231
-
232
- Options:
233
- -h, --help Show help [boolean]
234
- -v, -V, --version Show version number [boolean]
235
-
236
-
237
- Examples:
238
-
239
- - Output nothing more than stdout+stderr of child processes
240
-
241
- $ concurrently --raw "npm run watch-less" "npm run watch-js"
242
-
243
- - Normal output but without colors e.g. when logging to file
244
-
245
- $ concurrently --no-color "grunt watch" "http-server" > log
246
-
247
- - Custom prefix
248
-
249
- $ concurrently --prefix "{time}-{pid}" "npm run watch" "http-server"
250
-
251
- - Custom names and colored prefixes
252
-
253
- $ concurrently --names "HTTP,WATCH" -c "bgBlue.bold,bgMagenta.bold"
254
- "http-server" "npm run watch"
255
-
256
- - Auto varying colored prefixes
257
-
258
- $ concurrently -c "auto" "npm run watch" "http-server"
259
-
260
- - Mixing auto and manual colored prefixes
261
-
262
- $ concurrently -c "red,auto" "npm run watch" "http-server" "echo hello"
263
-
264
- - Configuring via environment variables with CONCURRENTLY_ prefix
265
-
266
- $ CONCURRENTLY_RAW=true CONCURRENTLY_KILL_OTHERS=true concurrently "echo
267
- hello" "echo world"
268
-
269
- - Send input to default
270
-
271
- $ concurrently --handle-input "nodemon" "npm run watch-js"
272
- rs # Sends rs command to nodemon process
273
-
274
- - Send input to specific child identified by index
275
-
276
- $ concurrently --handle-input "npm run watch-js" nodemon
277
- 1:rs
278
-
279
- - Send input to specific child identified by name
280
-
281
- $ concurrently --handle-input -n js,srv "npm run watch-js" nodemon
282
- srv:rs
283
-
284
- - Shortened NPM run commands
285
-
286
- $ concurrently npm:watch-node npm:watch-js npm:watch-css
287
-
288
- - Shortened NPM run command with wildcard (make sure to wrap it in quotes!)
289
-
290
- $ concurrently "npm:watch-*"
291
-
292
- - Exclude patterns so that between "lint:js" and "lint:fix:js", only "lint:js"
293
- is ran
294
-
295
- $ concurrently "npm:*(!fix)"
296
-
297
- - Passthrough some additional arguments via '{<number>}' placeholder
298
-
299
- $ concurrently -P "echo {1}" -- foo
300
-
301
- - Passthrough all additional arguments via '{@}' placeholder
302
-
303
- $ concurrently -P "npm:dev-* -- {@}" -- --watch --noEmit
304
-
305
- - Passthrough all additional arguments combined via '{*}' placeholder
306
-
307
- $ concurrently -P "npm:dev-* -- {*}" -- --watch --noEmit
308
-
309
- For more details, visit https://github.com/open-cli-tools/concurrently
310
- ```
79
+ Check out documentation and other usage examples in the [`docs` directory](./docs/README.md).
311
80
 
312
81
  ## API
313
82
 
@@ -316,7 +85,7 @@ For more details, visit https://github.com/open-cli-tools/concurrently
316
85
  ### `concurrently(commands[, options])`
317
86
 
318
87
  - `commands`: an array of either strings (containing the commands to run) or objects
319
- with the shape `{ command, name, prefixColor, env, cwd }`.
88
+ with the shape `{ command, name, prefixColor, env, cwd, ipc }`.
320
89
 
321
90
  - `options` (optional): an object containing any of the below:
322
91
  - `cwd`: the working directory to be used by all commands. Can be overriden per command.
@@ -335,7 +104,7 @@ For more details, visit https://github.com/open-cli-tools/concurrently
335
104
  - `prefix`: the prefix type to use when logging processes output.
336
105
  Possible values: `index`, `pid`, `time`, `command`, `name`, `none`, or a template (eg `[{time} process: {pid}]`).
337
106
  Default: the name of the process, or its index if no name is set.
338
- - `prefixColors`: a list of colors as supported by [chalk](https://www.npmjs.com/package/chalk) or `auto` for an automatically picked color.
107
+ - `prefixColors`: a list of colors or a string as supported by [chalk](https://www.npmjs.com/package/chalk) and additional style `auto` for an automatically picked color.
339
108
  If concurrently would run more commands than there are colors, the last color is repeated, unless if the last color value is `auto` which means following colors are automatically picked to vary.
340
109
  Prefix colors specified per-command take precedence over this list.
341
110
  - `prefixLength`: how many characters to show when prefixing with `command`. Default: `10`
@@ -346,7 +115,7 @@ For more details, visit https://github.com/open-cli-tools/concurrently
346
115
  Anything else means all processes should exit successfully.
347
116
  - `restartTries`: how many attempts to restart a process that dies will be made. Default: `0`.
348
117
  - `restartDelay`: how many milliseconds to wait between process restarts. Default: `0`.
349
- - `timestampFormat`: a [date-fns format](https://date-fns.org/v2.0.1/docs/format)
118
+ - `timestampFormat`: a [Unicode format](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table)
350
119
  to use when prefixing with `time`. Default: `yyyy-MM-dd HH:mm:ss.ZZZ`
351
120
  - `additionalArguments`: list of additional arguments passed that will get replaced in each command. If not defined, no argument replacing will happen.
352
121
 
@@ -392,18 +161,44 @@ It has the following properties:
392
161
  - `cwd`: the current working directory of the command.
393
162
  - `env`: an object with all the environment variables that the command will be spawned with.
394
163
  - `killed`: whether the command has been killed.
395
- - `exited`: whether the command exited yet.
164
+ - `state`: the command's state. Can be one of
165
+ - `stopped`: if the command was never started
166
+ - `started`: if the command is currently running
167
+ - `errored`: if the command failed spawning
168
+ - `exited`: if the command is not running anymore, e.g. it received a close event
396
169
  - `pid`: the command's process ID.
397
170
  - `stdin`: a Writable stream to the command's `stdin`.
398
171
  - `stdout`: an RxJS observable to the command's `stdout`.
399
172
  - `stderr`: an RxJS observable to the command's `stderr`.
400
173
  - `error`: an RxJS observable to the command's error events (e.g. when it fails to spawn).
401
174
  - `timer`: an RxJS observable to the command's timing events (e.g. starting, stopping).
175
+ - `messages`: an object with the following properties:
176
+
177
+ - `incoming`: an RxJS observable for the IPC messages received from the underlying process.
178
+ - `outgoing`: an RxJS observable for the IPC messages sent to the underlying process.
179
+
180
+ Both observables emit [`MessageEvent`](#messageevent)s.<br>
181
+ Note that if the command wasn't spawned with IPC support, these won't emit any values.
182
+
402
183
  - `close`: an RxJS observable to the command's close events.
403
184
  See [`CloseEvent`](#CloseEvent) for more information.
404
- - `start()`: starts the command, setting up all
185
+ - `start()`: starts the command and sets up all of the above streams
186
+ - `send(message[, handle, options])`: sends a message to the underlying process via IPC channels,
187
+ returning a promise that resolves once the message has been sent.
188
+ See [Node.js docs](https://nodejs.org/docs/latest/api/child_process.html#subprocesssendmessage-sendhandle-options-callback).
405
189
  - `kill([signal])`: kills the command, optionally specifying a signal (e.g. `SIGTERM`, `SIGKILL`, etc).
406
190
 
191
+ ### `MessageEvent`
192
+
193
+ An object that represents a message that was received from/sent to the underlying command process.<br>
194
+ It has the following properties:
195
+
196
+ - `message`: the message itself.
197
+ - `handle`: a [`net.Socket`](https://nodejs.org/docs/latest/api/net.html#class-netsocket),
198
+ [`net.Server`](https://nodejs.org/docs/latest/api/net.html#class-netserver) or
199
+ [`dgram.Socket`](https://nodejs.org/docs/latest/api/dgram.html#class-dgramsocket),
200
+ if one was sent, or `undefined`.
201
+
407
202
  ### `CloseEvent`
408
203
 
409
204
  An object with information about a command's closing event.<br>
@@ -27,24 +27,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
+ const lodash_1 = __importDefault(require("lodash"));
30
31
  const yargs_1 = __importDefault(require("yargs"));
31
32
  const helpers_1 = require("yargs/helpers");
32
33
  const defaults = __importStar(require("../src/defaults"));
33
- const index_1 = __importDefault(require("../src/index"));
34
- const epilogue_1 = require("./epilogue");
34
+ const index_1 = require("../src/index");
35
+ const read_package_1 = require("./read-package");
36
+ const version = String((0, read_package_1.readPackage)().version);
37
+ const epilogue = `For documentation and more examples, visit:\nhttps://github.com/open-cli-tools/concurrently/tree/v${version}/docs`;
35
38
  // 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)
39
+ const args = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
40
+ .parserConfiguration({
41
+ // Avoids options that can be specified multiple times from requiring a `--` to pass commands
42
+ 'greedy-arrays': false,
43
+ // Makes sure that --passthrough-arguments works correctly
44
+ 'populate--': true,
45
+ })
44
46
  .usage('$0 [options] <command ...>')
45
47
  .help('h')
46
48
  .alias('h', 'help')
47
- .version()
49
+ .version(version)
48
50
  .alias('version', 'v')
49
51
  .alias('version', 'V')
50
52
  // TODO: Add some tests for this.
@@ -117,6 +119,12 @@ const args = (0, yargs_1.default)(argsBeforeSep)
117
119
  type: 'boolean',
118
120
  default: defaults.passthroughArguments,
119
121
  },
122
+ teardown: {
123
+ describe: 'Clean up command(s) to execute before exiting concurrently. Might be specified multiple times.\n' +
124
+ "These aren't prefixed and they don't affect concurrently's exit code.",
125
+ type: 'string',
126
+ array: true,
127
+ },
120
128
  // Kill others
121
129
  'kill-others': {
122
130
  alias: 'k',
@@ -161,9 +169,14 @@ const args = (0, yargs_1.default)(argsBeforeSep)
161
169
  default: defaults.prefixLength,
162
170
  type: 'number',
163
171
  },
172
+ 'pad-prefix': {
173
+ describe: 'Pads short prefixes with spaces so that the length of all prefixes match',
174
+ type: 'boolean',
175
+ },
164
176
  'timestamp-format': {
165
177
  alias: 't',
166
- describe: 'Specify the timestamp in moment/date-fns format.',
178
+ describe: 'Specify the timestamp in Unicode format:\n' +
179
+ 'https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table',
167
180
  default: defaults.timestampFormat,
168
181
  type: 'string',
169
182
  },
@@ -175,9 +188,9 @@ const args = (0, yargs_1.default)(argsBeforeSep)
175
188
  type: 'number',
176
189
  },
177
190
  'restart-after': {
178
- describe: 'Delay time to respawn the process, in milliseconds.',
191
+ describe: 'Delay before restarting the process, in milliseconds, or "exponential".',
179
192
  default: defaults.restartDelay,
180
- type: 'number',
193
+ type: 'string',
181
194
  },
182
195
  // Input
183
196
  'handle-input': {
@@ -193,18 +206,18 @@ const args = (0, yargs_1.default)(argsBeforeSep)
193
206
  'Can be either the index or the name of the process.',
194
207
  },
195
208
  })
196
- .group(['m', 'n', 'name-separator', 's', 'r', 'no-color', 'hide', 'g', 'timings', 'P'], 'General')
197
- .group(['p', 'c', 'l', 't'], 'Prefix styling')
209
+ .group(['m', 'n', 'name-separator', 's', 'r', 'no-color', 'hide', 'g', 'timings', 'P', 'teardown'], 'General')
210
+ .group(['p', 'c', 'l', 't', 'pad-prefix'], 'Prefix styling')
198
211
  .group(['i', 'default-input-target'], 'Input handling')
199
212
  .group(['k', 'kill-others-on-fail', 'kill-signal'], 'Killing other processes')
200
213
  .group(['restart-tries', 'restart-after'], 'Restarting')
201
- .epilogue(epilogue_1.epilogue)
214
+ .epilogue(epilogue)
202
215
  .parseSync();
203
216
  // Get names of commands by the specified separator
204
217
  const names = (args.names || '').split(args.nameSeparator);
205
- // If "passthrough-arguments" is disabled, treat additional arguments as commands
206
- const commands = args.passthroughArguments ? args._ : [...args._, ...argsAfterSep];
207
- (0, index_1.default)(commands.map((command, index) => ({
218
+ const additionalArguments = lodash_1.default.castArray(args['--'] ?? []).map(String);
219
+ const commands = args.passthroughArguments ? args._ : args._.concat(additionalArguments);
220
+ (0, index_1.concurrently)(commands.map((command, index) => ({
208
221
  command: String(command),
209
222
  name: names[index],
210
223
  })), {
@@ -223,10 +236,12 @@ const commands = args.passthroughArguments ? args._ : [...args._, ...argsAfterSe
223
236
  prefix: args.prefix,
224
237
  prefixColors: args.prefixColors.split(','),
225
238
  prefixLength: args.prefixLength,
226
- restartDelay: args.restartAfter,
239
+ padPrefix: args.padPrefix,
240
+ restartDelay: args.restartAfter === 'exponential' ? 'exponential' : Number(args.restartAfter),
227
241
  restartTries: args.restartTries,
228
242
  successCondition: args.success,
229
243
  timestampFormat: args.timestampFormat,
230
244
  timings: args.timings,
231
- additionalArguments: args.passthroughArguments ? argsAfterSep : undefined,
245
+ teardown: args.teardown,
246
+ additionalArguments: args.passthroughArguments ? additionalArguments : undefined,
232
247
  }).result.then(() => process.exit(0), () => process.exit(1));
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Traverses the directory tree until a package.json file is found.
3
+ *
4
+ * @throws if the root directory is reached, and no package.json is found.
5
+ */
6
+ export declare function readPackage(): Record<string, unknown>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = 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);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.readPackage = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ const path = __importStar(require("path"));
29
+ /**
30
+ * Traverses the directory tree until a package.json file is found.
31
+ *
32
+ * @throws if the root directory is reached, and no package.json is found.
33
+ */
34
+ function readPackage() {
35
+ let dir = require.main?.path ?? process.cwd();
36
+ let oldDir = dir;
37
+ do {
38
+ const pkgPath = path.join(dir, 'package.json');
39
+ if (fs.existsSync(pkgPath)) {
40
+ return JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
41
+ }
42
+ oldDir = dir;
43
+ dir = path.dirname(dir);
44
+ } while (oldDir !== dir);
45
+ throw new Error('package.json not found');
46
+ }
47
+ exports.readPackage = readPackage;
@@ -12,6 +12,7 @@ export declare class ExpandArguments implements CommandParser {
12
12
  env?: Record<string, unknown> | undefined;
13
13
  cwd?: string | undefined;
14
14
  prefixColor?: string | undefined;
15
+ ipc?: number | undefined;
15
16
  raw?: boolean | undefined;
16
17
  };
17
18
  }
@@ -6,6 +6,7 @@ const shell_quote_1 = require("shell-quote");
6
6
  * Replace placeholders with additional arguments.
7
7
  */
8
8
  class ExpandArguments {
9
+ additionalArguments;
9
10
  constructor(additionalArguments) {
10
11
  this.additionalArguments = additionalArguments;
11
12
  }
@@ -1,7 +1,7 @@
1
1
  import { CommandInfo } from '../command';
2
2
  import { CommandParser } from './command-parser';
3
3
  /**
4
- * Expands commands prefixed with `npm:`, `yarn:`, `pnpm:`, or `bun:` into the full version `npm run <command>` and so on.
4
+ * Expands commands prefixed with `node:`, `npm:`, `yarn:`, `pnpm:`, or `bun:` into the full version `npm run <command>` and so on.
5
5
  */
6
6
  export declare class ExpandNpmShortcut implements CommandParser {
7
7
  parse(commandInfo: CommandInfo): CommandInfo;
@@ -2,18 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExpandNpmShortcut = void 0;
4
4
  /**
5
- * Expands commands prefixed with `npm:`, `yarn:`, `pnpm:`, or `bun:` into the full version `npm run <command>` and so on.
5
+ * Expands commands prefixed with `node:`, `npm:`, `yarn:`, `pnpm:`, or `bun:` into the full version `npm run <command>` and so on.
6
6
  */
7
7
  class ExpandNpmShortcut {
8
8
  parse(commandInfo) {
9
- const [, npmCmd, cmdName, args] = commandInfo.command.match(/^(npm|yarn|pnpm|bun):(\S+)(.*)/) || [];
9
+ const [, npmCmd, cmdName, args] = commandInfo.command.match(/^(node|npm|yarn|pnpm|bun):(\S+)(.*)/) || [];
10
10
  if (!cmdName) {
11
11
  return commandInfo;
12
12
  }
13
+ const runCmd = npmCmd === 'node' ? '--run' : 'run';
13
14
  return {
14
15
  ...commandInfo,
15
16
  name: commandInfo.name || cmdName,
16
- command: `${npmCmd} run ${cmdName}${args}`,
17
+ command: `${npmCmd} ${runCmd} ${cmdName}${args}`,
17
18
  };
18
19
  }
19
20
  }
@@ -12,6 +12,7 @@ const OMISSION = /\(!([^)]+)\)/;
12
12
  * `package.json` file of the current directory.
13
13
  */
14
14
  class ExpandNpmWildcard {
15
+ readPackage;
15
16
  static readPackage() {
16
17
  try {
17
18
  const json = fs_1.default.readFileSync('package.json', { encoding: 'utf-8' });
@@ -21,11 +22,12 @@ class ExpandNpmWildcard {
21
22
  return {};
22
23
  }
23
24
  }
25
+ scripts;
24
26
  constructor(readPackage = ExpandNpmWildcard.readPackage) {
25
27
  this.readPackage = readPackage;
26
28
  }
27
29
  parse(commandInfo) {
28
- const [, npmCmd, cmdName, args] = commandInfo.command.match(/(npm|yarn|pnpm|bun) run (\S+)([^&]*)/) || [];
30
+ const [, npmCmd, runCmd, cmdName, args] = commandInfo.command.match(/(node|npm|yarn|pnpm|bun) ((?:--)?run) (\S+)([^&]*)/) || [];
29
31
  const wildcardPosition = (cmdName || '').indexOf('*');
30
32
  // If the regex didn't match an npm script, or it has no wildcard,
31
33
  // then we have nothing to do here
@@ -55,7 +57,7 @@ class ExpandNpmWildcard {
55
57
  if (match) {
56
58
  return {
57
59
  ...commandInfo,
58
- command: `${npmCmd} run ${script}${args}`,
60
+ command: `${npmCmd} ${runCmd} ${script}${args}`,
59
61
  // Will use an empty command name if no prefix has been specified and
60
62
  // the wildcard match is empty, e.g. if `npm:watch-*` matches `npm run watch-`.
61
63
  name: prefix + match[1],
@@ -10,6 +10,7 @@ export declare class StripQuotes implements CommandParser {
10
10
  env?: Record<string, unknown> | undefined;
11
11
  cwd?: string | undefined;
12
12
  prefixColor?: string | undefined;
13
+ ipc?: number | undefined;
13
14
  raw?: boolean | undefined;
14
15
  };
15
16
  }