concurrently 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/package.json +1 -1
- package/src/command-parser/expand-npm-shortcut.js +1 -1
- package/src/command-parser/expand-npm-wildcard.js +1 -1
- package/src/command.js +12 -2
- package/src/completion-listener.js +4 -4
- package/src/flow-control/kill-on-signal.js +3 -2
- package/src/flow-control/kill-others.js +1 -1
- package/src/flow-control/log-exit.js +2 -2
- package/src/flow-control/restart-process.js +3 -3
- package/src/logger.js +1 -1
package/README.md
CHANGED
|
@@ -251,7 +251,10 @@ concurrently can be used programmatically by using the API documented below:
|
|
|
251
251
|
to use when prefixing with `time`. Default: `yyyy-MM-dd HH:mm:ss.ZZZ`
|
|
252
252
|
|
|
253
253
|
> Returns: a `Promise` that resolves if the run was successful (according to `successCondition` option),
|
|
254
|
-
> or rejects, containing an array
|
|
254
|
+
> or rejects, containing an array of objects with information for each command that has been run, in the order
|
|
255
|
+
> that the commands terminated. The objects have the shape `{ command, index, exitCode }`, where `command` is the object
|
|
256
|
+
> passed in the `commands` array and `index` its index there. Default values (empty strings or objects) are returned for
|
|
257
|
+
> the fields that were not specified.
|
|
255
258
|
|
|
256
259
|
Example:
|
|
257
260
|
|
|
@@ -283,6 +286,6 @@ concurrently([
|
|
|
283
286
|
So *null* means the process didn't terminate normally. This will make **concurrent**
|
|
284
287
|
to return non-zero exit code too.
|
|
285
288
|
|
|
286
|
-
* Does this work with the npm-
|
|
289
|
+
* Does this work with the npm-replacements [yarn](https://github.com/yarnpkg/yarn) or [pnpm](https://pnpm.js.org/)?
|
|
287
290
|
|
|
288
|
-
Yes! In all examples above, you may replace "`npm`" with "`yarn`".
|
|
291
|
+
Yes! In all examples above, you may replace "`npm`" with "`yarn`" or "`pnpm`".
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module.exports = class ExpandNpmShortcut {
|
|
2
2
|
parse(commandInfo) {
|
|
3
|
-
const [, npmCmd, cmdName, args] = commandInfo.command.match(/^(npm|yarn):(\S+)(.*)/) || [];
|
|
3
|
+
const [, npmCmd, cmdName, args] = commandInfo.command.match(/^(npm|yarn|pnpm):(\S+)(.*)/) || [];
|
|
4
4
|
if (!cmdName) {
|
|
5
5
|
return commandInfo;
|
|
6
6
|
}
|
|
@@ -7,7 +7,7 @@ module.exports = class ExpandNpmWildcard {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
parse(commandInfo) {
|
|
10
|
-
const [, npmCmd, cmdName, args] = commandInfo.command.match(/(npm|yarn) run (\S+)([^&]*)/) || [];
|
|
10
|
+
const [, npmCmd, cmdName, args] = commandInfo.command.match(/(npm|yarn|pnpm) run (\S+)([^&]*)/) || [];
|
|
11
11
|
const wildcardPosition = (cmdName || '').indexOf('*');
|
|
12
12
|
|
|
13
13
|
// If the regex didn't match an npm script, or it has no wildcard,
|
package/src/command.js
CHANGED
|
@@ -5,11 +5,12 @@ module.exports = class Command {
|
|
|
5
5
|
return !!this.process;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
constructor({ index, name, command, prefixColor, killProcess, spawn, spawnOpts }) {
|
|
8
|
+
constructor({ index, name, command, prefixColor, env, killProcess, spawn, spawnOpts }) {
|
|
9
9
|
this.index = index;
|
|
10
10
|
this.name = name;
|
|
11
11
|
this.command = command;
|
|
12
12
|
this.prefixColor = prefixColor;
|
|
13
|
+
this.env = env;
|
|
13
14
|
this.killProcess = killProcess;
|
|
14
15
|
this.spawn = spawn;
|
|
15
16
|
this.spawnOpts = spawnOpts;
|
|
@@ -31,7 +32,16 @@ module.exports = class Command {
|
|
|
31
32
|
});
|
|
32
33
|
Rx.fromEvent(child, 'close').subscribe(([exitCode, signal]) => {
|
|
33
34
|
this.process = undefined;
|
|
34
|
-
this.close.next(
|
|
35
|
+
this.close.next({
|
|
36
|
+
command: {
|
|
37
|
+
command: this.command,
|
|
38
|
+
name: this.name,
|
|
39
|
+
prefixColor: this.prefixColor,
|
|
40
|
+
env: this.env,
|
|
41
|
+
},
|
|
42
|
+
index: this.index,
|
|
43
|
+
exitCode: exitCode === null ? signal : exitCode,
|
|
44
|
+
});
|
|
35
45
|
});
|
|
36
46
|
child.stdout && pipeTo(Rx.fromEvent(child.stdout, 'data'), this.stdout);
|
|
37
47
|
child.stderr && pipeTo(Rx.fromEvent(child.stderr, 'data'), this.stderr);
|
|
@@ -27,10 +27,10 @@ module.exports = class CompletionListener {
|
|
|
27
27
|
return Rx.merge(...closeStreams)
|
|
28
28
|
.pipe(
|
|
29
29
|
bufferCount(closeStreams.length),
|
|
30
|
-
switchMap(
|
|
31
|
-
this.isSuccess(
|
|
32
|
-
? Rx.of(
|
|
33
|
-
: Rx.throwError(
|
|
30
|
+
switchMap(exitInfos =>
|
|
31
|
+
this.isSuccess(exitInfos.map(({ exitCode }) => exitCode))
|
|
32
|
+
? Rx.of(exitInfos, this.scheduler)
|
|
33
|
+
: Rx.throwError(exitInfos, this.scheduler)
|
|
34
34
|
),
|
|
35
35
|
take(1)
|
|
36
36
|
)
|
|
@@ -16,8 +16,9 @@ module.exports = class KillOnSignal {
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
return commands.map(command => {
|
|
19
|
-
const closeStream = command.close.pipe(map(
|
|
20
|
-
|
|
19
|
+
const closeStream = command.close.pipe(map(exitInfo => {
|
|
20
|
+
const exitCode = caughtSignal === 'SIGINT' ? 0 : exitInfo.exitCode;
|
|
21
|
+
return Object.assign({}, exitInfo, { exitCode });
|
|
21
22
|
}));
|
|
22
23
|
return new Proxy(command, {
|
|
23
24
|
get(target, prop) {
|
|
@@ -18,7 +18,7 @@ module.exports = class KillOthers {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const closeStates = commands.map(command => command.close.pipe(
|
|
21
|
-
map(exitCode => exitCode === 0 ? 'success' : 'failure'),
|
|
21
|
+
map(({ exitCode }) => exitCode === 0 ? 'success' : 'failure'),
|
|
22
22
|
filter(state => conditions.includes(state))
|
|
23
23
|
));
|
|
24
24
|
|
|
@@ -4,8 +4,8 @@ module.exports = class LogExit {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
handle(commands) {
|
|
7
|
-
commands.forEach(command => command.close.subscribe(
|
|
8
|
-
this.logger.logCommandEvent(`${command.command} exited with code ${
|
|
7
|
+
commands.forEach(command => command.close.subscribe(({ exitCode }) => {
|
|
8
|
+
this.logger.logCommandEvent(`${command.command} exited with code ${exitCode}`, command);
|
|
9
9
|
}));
|
|
10
10
|
|
|
11
11
|
return commands;
|
|
@@ -18,7 +18,7 @@ module.exports = class RestartProcess {
|
|
|
18
18
|
|
|
19
19
|
commands.map(command => command.close.pipe(
|
|
20
20
|
take(this.tries),
|
|
21
|
-
takeWhile(
|
|
21
|
+
takeWhile(({ exitCode }) => exitCode !== 0)
|
|
22
22
|
)).map((failure, index) => Rx.merge(
|
|
23
23
|
// Delay the emission (so that the restarts happen on time),
|
|
24
24
|
// explicitly telling the subscriber that a restart is needed
|
|
@@ -36,9 +36,9 @@ module.exports = class RestartProcess {
|
|
|
36
36
|
}));
|
|
37
37
|
|
|
38
38
|
return commands.map(command => {
|
|
39
|
-
const closeStream = command.close.pipe(filter((
|
|
39
|
+
const closeStream = command.close.pipe(filter(({ exitCode }, emission) => {
|
|
40
40
|
// We let all success codes pass, and failures only after restarting won't happen again
|
|
41
|
-
return
|
|
41
|
+
return exitCode === 0 || emission >= this.tries;
|
|
42
42
|
}));
|
|
43
43
|
|
|
44
44
|
return new Proxy(command, {
|
package/src/logger.js
CHANGED
|
@@ -53,7 +53,7 @@ module.exports = class Logger {
|
|
|
53
53
|
return _.reduce(prefixes, (prev, val, key) => {
|
|
54
54
|
const keyRegex = new RegExp(_.escapeRegExp(`{${key}}`), 'g');
|
|
55
55
|
return prev.replace(keyRegex, val);
|
|
56
|
-
}, prefix)
|
|
56
|
+
}, prefix);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
colorText(command, text) {
|