concurrently 6.1.0 → 6.2.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 CHANGED
@@ -169,9 +169,10 @@ Killing other processes
169
169
  code [boolean]
170
170
 
171
171
  Restarting
172
- --restart-tries How many times a process that died should restart.
172
+ --restart-tries How many times a process that died should restart.
173
+ Negative numbers will make the process restart forever.
173
174
  [number] [default: 0]
174
- --restart-after Delay time to respawn the process, in milliseconds.
175
+ --restart-after Delay time to respawn the process, in milliseconds.
175
176
  [number] [default: 0]
176
177
 
177
178
  Options:
@@ -257,9 +258,9 @@ concurrently can be used programmatically by using the API documented below:
257
258
 
258
259
  > Returns: a `Promise` that resolves if the run was successful (according to `successCondition` option),
259
260
  > or rejects, containing an array of objects with information for each command that has been run, in the order
260
- > that the commands terminated. The objects have the shape `{ command, index, exitCode }`, where `command` is the object
261
- > passed in the `commands` array and `index` its index there. Default values (empty strings or objects) are returned for
262
- > the fields that were not specified.
261
+ > that the commands terminated. The objects have the shape `{ command, index, exitCode, killed }`, where `command` is the object
262
+ > passed in the `commands` array, `index` its index there and `killed` indicates if the process was killed as a result of
263
+ > `killOthers`. Default values (empty strings or objects) are returned for the fields that were not specified.
263
264
 
264
265
  Example:
265
266
 
@@ -107,7 +107,9 @@ const args = yargs
107
107
 
108
108
  // Restarting
109
109
  'restart-tries': {
110
- describe: 'How many times a process that died should restart.',
110
+ describe:
111
+ 'How many times a process that died should restart.\n' +
112
+ 'Negative numbers will make the process restart forever.',
111
113
  default: defaults.restartTries,
112
114
  type: 'number'
113
115
  },
@@ -300,7 +300,7 @@ describe('--kill-others-on-fail', () => {
300
300
  });
301
301
 
302
302
  describe('--handle-input', () => {
303
- it('is alised to -i', done => {
303
+ it('is aliased to -i', done => {
304
304
  const child = run('-i "node fixtures/read-echo.js"');
305
305
  child.log.subscribe(line => {
306
306
  if (/READING/.test(line)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "concurrently",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "description": "Run commands concurrently",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/command.js CHANGED
@@ -14,6 +14,7 @@ module.exports = class Command {
14
14
  this.killProcess = killProcess;
15
15
  this.spawn = spawn;
16
16
  this.spawnOpts = spawnOpts;
17
+ this.killed = false;
17
18
 
18
19
  this.error = new Rx.Subject();
19
20
  this.close = new Rx.Subject();
@@ -41,6 +42,7 @@ module.exports = class Command {
41
42
  },
42
43
  index: this.index,
43
44
  exitCode: exitCode === null ? signal : exitCode,
45
+ killed: this.killed,
44
46
  });
45
47
  });
46
48
  child.stdout && pipeTo(Rx.fromEvent(child.stdout, 'data'), this.stdout);
@@ -50,6 +52,7 @@ module.exports = class Command {
50
52
 
51
53
  kill(code) {
52
54
  if (this.killable) {
55
+ this.killed = true;
53
56
  this.killProcess(this.pid, code);
54
57
  }
55
58
  }
@@ -60,6 +60,7 @@ describe('#start()', () => {
60
60
 
61
61
  command.close.subscribe(data => {
62
62
  expect(data.exitCode).toBe(0);
63
+ expect(data.killed).toBe(false);
63
64
  expect(command.process).toBeUndefined();
64
65
  done();
65
66
  });
@@ -74,6 +75,7 @@ describe('#start()', () => {
74
75
 
75
76
  command.close.subscribe(data => {
76
77
  expect(data.exitCode).toBe('SIGKILL');
78
+ expect(data.killed).toBe(false);
77
79
  done();
78
80
  });
79
81
 
@@ -98,6 +100,7 @@ describe('#start()', () => {
98
100
 
99
101
  command.close.subscribe(data => {
100
102
  expect(data.command).toEqual(commandInfo);
103
+ expect(data.killed).toBe(false);
101
104
  expect(data.index).toBe(1);
102
105
  done();
103
106
  });
@@ -164,4 +167,17 @@ describe('#kill()', () => {
164
167
 
165
168
  expect(killProcess).not.toHaveBeenCalled();
166
169
  });
170
+
171
+ it('marks the command as killed', done => {
172
+ command.start();
173
+
174
+ command.close.subscribe(data => {
175
+ expect(data.exitCode).toBe(1);
176
+ expect(data.killed).toBe(true);
177
+ done();
178
+ });
179
+
180
+ command.kill();
181
+ process.emit('close', 1, null);
182
+ });
167
183
  });
@@ -1,5 +1,5 @@
1
1
  const Rx = require('rxjs');
2
- const { bufferCount, map, switchMap, take } = require('rxjs/operators');
2
+ const { bufferCount, switchMap, take } = require('rxjs/operators');
3
3
 
4
4
  module.exports = class CompletionListener {
5
5
  constructor({ successCondition, scheduler }) {
@@ -7,6 +7,7 @@ module.exports = class RestartProcess {
7
7
  constructor({ delay, tries, logger, scheduler }) {
8
8
  this.delay = +delay || defaults.restartDelay;
9
9
  this.tries = +tries || defaults.restartTries;
10
+ this.tries = this.tries < 0 ? Infinity : this.tries;
10
11
  this.logger = logger;
11
12
  this.scheduler = scheduler;
12
13
  }
@@ -69,6 +69,8 @@ it('restarts processes up to tries', () => {
69
69
  expect(commands[0].start).toHaveBeenCalledTimes(2);
70
70
  });
71
71
 
72
+ it.todo('restart processes forever, if tries is negative');
73
+
72
74
  it('restarts processes until they succeed', () => {
73
75
  controller.handle(commands);
74
76