concurrently 4.1.2 → 5.1.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 +4 -8
- package/bin/epilogue.txt +0 -4
- package/package.json +12 -5
- package/src/completion-listener.js +26 -22
- package/src/defaults.js +2 -2
- package/src/flow-control/kill-on-signal.js +1 -1
- package/src/get-spawn-opts.js +1 -1
- package/.editorconfig +0 -28
- package/.eslintrc.json +0 -23
- package/.travis.yml +0 -11
- package/.vscode/settings.json +0 -6
- package/CONTRIBUTING.md +0 -23
- package/appveyor.yml +0 -18
- package/bin/concurrently.spec.js +0 -365
- package/bin/fixtures/read-echo.js +0 -10
- package/docs/demo.gif +0 -0
- package/docs/frontend-demo.gif +0 -0
- package/docs/kill-demo.gif +0 -0
- package/docs/raw-demo.gif +0 -0
- package/src/command-parser/expand-npm-shortcut.spec.js +0 -36
- package/src/command-parser/expand-npm-wildcard.spec.js +0 -58
- package/src/command-parser/strip-quotes.spec.js +0 -20
- package/src/command.spec.js +0 -142
- package/src/completion-listener.spec.js +0 -88
- package/src/concurrently.spec.js +0 -77
- package/src/flow-control/input-handler.spec.js +0 -79
- package/src/flow-control/kill-on-signal.spec.js +0 -70
- package/src/flow-control/kill-others.spec.js +0 -66
- package/src/flow-control/log-error.spec.js +0 -40
- package/src/flow-control/log-exit.spec.js +0 -36
- package/src/flow-control/log-output.spec.js +0 -41
- package/src/flow-control/restart-process.spec.js +0 -129
- package/src/get-spawn-opts.spec.js +0 -18
- package/src/logger.spec.js +0 -178
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const { createMockInstance } = require('jest-create-mock-instance');
|
|
2
|
-
const Logger = require('../logger');
|
|
3
|
-
const LogExit = require('./log-exit');
|
|
4
|
-
const createFakeCommand = require('./fixtures/fake-command');
|
|
5
|
-
|
|
6
|
-
let controller, logger, commands;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
commands = [
|
|
9
|
-
createFakeCommand(),
|
|
10
|
-
createFakeCommand(),
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
logger = createMockInstance(Logger);
|
|
14
|
-
controller = new LogExit({ logger });
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('returns same commands', () => {
|
|
18
|
-
expect(controller.handle(commands)).toBe(commands);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('logs the close event of each command', () => {
|
|
22
|
-
controller.handle(commands);
|
|
23
|
-
|
|
24
|
-
commands[0].close.next(0);
|
|
25
|
-
commands[1].close.next('SIGTERM');
|
|
26
|
-
|
|
27
|
-
expect(logger.logCommandEvent).toHaveBeenCalledTimes(2);
|
|
28
|
-
expect(logger.logCommandEvent).toHaveBeenCalledWith(
|
|
29
|
-
`${commands[0].command} exited with code 0`,
|
|
30
|
-
commands[0]
|
|
31
|
-
);
|
|
32
|
-
expect(logger.logCommandEvent).toHaveBeenCalledWith(
|
|
33
|
-
`${commands[1].command} exited with code SIGTERM`,
|
|
34
|
-
commands[1]
|
|
35
|
-
);
|
|
36
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const { createMockInstance } = require('jest-create-mock-instance');
|
|
2
|
-
const Logger = require('../logger');
|
|
3
|
-
const LogOutput = require('./log-output');
|
|
4
|
-
const createFakeCommand = require('./fixtures/fake-command');
|
|
5
|
-
|
|
6
|
-
let controller, logger, commands;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
commands = [
|
|
9
|
-
createFakeCommand(),
|
|
10
|
-
createFakeCommand(),
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
logger = createMockInstance(Logger);
|
|
14
|
-
controller = new LogOutput({ logger });
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('returns same commands', () => {
|
|
18
|
-
expect(controller.handle(commands)).toBe(commands);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('logs the stdout of each command', () => {
|
|
22
|
-
controller.handle(commands);
|
|
23
|
-
|
|
24
|
-
commands[0].stdout.next(Buffer.from('foo'));
|
|
25
|
-
commands[1].stdout.next(Buffer.from('bar'));
|
|
26
|
-
|
|
27
|
-
expect(logger.logCommandText).toHaveBeenCalledTimes(2);
|
|
28
|
-
expect(logger.logCommandText).toHaveBeenCalledWith('foo', commands[0]);
|
|
29
|
-
expect(logger.logCommandText).toHaveBeenCalledWith('bar', commands[1]);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('logs the stderr of each command', () => {
|
|
33
|
-
controller.handle(commands);
|
|
34
|
-
|
|
35
|
-
commands[0].stderr.next(Buffer.from('foo'));
|
|
36
|
-
commands[1].stderr.next(Buffer.from('bar'));
|
|
37
|
-
|
|
38
|
-
expect(logger.logCommandText).toHaveBeenCalledTimes(2);
|
|
39
|
-
expect(logger.logCommandText).toHaveBeenCalledWith('foo', commands[0]);
|
|
40
|
-
expect(logger.logCommandText).toHaveBeenCalledWith('bar', commands[1]);
|
|
41
|
-
});
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
const { createMockInstance } = require('jest-create-mock-instance');
|
|
2
|
-
const { TestScheduler } = require('rxjs/testing');
|
|
3
|
-
|
|
4
|
-
const Logger = require('../logger');
|
|
5
|
-
const createFakeCommand = require('./fixtures/fake-command');
|
|
6
|
-
const RestartProcess = require('./restart-process');
|
|
7
|
-
|
|
8
|
-
let commands, controller, logger, scheduler;
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
commands = [
|
|
11
|
-
createFakeCommand(),
|
|
12
|
-
createFakeCommand()
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
logger = createMockInstance(Logger);
|
|
16
|
-
scheduler = new TestScheduler();
|
|
17
|
-
controller = new RestartProcess({
|
|
18
|
-
logger,
|
|
19
|
-
scheduler,
|
|
20
|
-
delay: 100,
|
|
21
|
-
tries: 2
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('does not restart processes that complete with success', () => {
|
|
26
|
-
controller.handle(commands);
|
|
27
|
-
|
|
28
|
-
commands[0].close.next(0);
|
|
29
|
-
commands[1].close.next(0);
|
|
30
|
-
|
|
31
|
-
scheduler.flush();
|
|
32
|
-
|
|
33
|
-
expect(commands[0].start).toHaveBeenCalledTimes(0);
|
|
34
|
-
expect(commands[1].start).toHaveBeenCalledTimes(0);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('restarts processes that fail after delay has passed', () => {
|
|
38
|
-
controller.handle(commands);
|
|
39
|
-
|
|
40
|
-
commands[0].close.next(1);
|
|
41
|
-
commands[1].close.next(0);
|
|
42
|
-
|
|
43
|
-
scheduler.flush();
|
|
44
|
-
|
|
45
|
-
expect(logger.logCommandEvent).toHaveBeenCalledTimes(1);
|
|
46
|
-
expect(logger.logCommandEvent).toHaveBeenCalledWith(
|
|
47
|
-
`${commands[0].command} restarted`,
|
|
48
|
-
commands[0]
|
|
49
|
-
);
|
|
50
|
-
expect(commands[0].start).toHaveBeenCalledTimes(1);
|
|
51
|
-
expect(commands[1].start).not.toHaveBeenCalled();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('restarts processes up to tries', () => {
|
|
55
|
-
controller.handle(commands);
|
|
56
|
-
|
|
57
|
-
commands[0].close.next(1);
|
|
58
|
-
commands[0].close.next('SIGTERM');
|
|
59
|
-
commands[0].close.next('SIGTERM');
|
|
60
|
-
commands[1].close.next(0);
|
|
61
|
-
|
|
62
|
-
scheduler.flush();
|
|
63
|
-
|
|
64
|
-
expect(logger.logCommandEvent).toHaveBeenCalledTimes(2);
|
|
65
|
-
expect(logger.logCommandEvent).toHaveBeenCalledWith(
|
|
66
|
-
`${commands[0].command} restarted`,
|
|
67
|
-
commands[0]
|
|
68
|
-
);
|
|
69
|
-
expect(commands[0].start).toHaveBeenCalledTimes(2);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('restarts processes until they succeed', () => {
|
|
73
|
-
controller.handle(commands);
|
|
74
|
-
|
|
75
|
-
commands[0].close.next(1);
|
|
76
|
-
commands[0].close.next(0);
|
|
77
|
-
commands[1].close.next(0);
|
|
78
|
-
|
|
79
|
-
scheduler.flush();
|
|
80
|
-
|
|
81
|
-
expect(logger.logCommandEvent).toHaveBeenCalledTimes(1);
|
|
82
|
-
expect(logger.logCommandEvent).toHaveBeenCalledWith(
|
|
83
|
-
`${commands[0].command} restarted`,
|
|
84
|
-
commands[0]
|
|
85
|
-
);
|
|
86
|
-
expect(commands[0].start).toHaveBeenCalledTimes(1);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe('returned commands', () => {
|
|
90
|
-
it('are the same if 0 tries are to be attempted', () => {
|
|
91
|
-
controller = new RestartProcess({ logger, scheduler });
|
|
92
|
-
expect(controller.handle(commands)).toBe(commands);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('are not the same, but with same length if 1+ tries are to be attempted', () => {
|
|
96
|
-
const newCommands = controller.handle(commands);
|
|
97
|
-
expect(newCommands).not.toBe(commands);
|
|
98
|
-
expect(newCommands).toHaveLength(commands.length);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('skip close events followed by restarts', () => {
|
|
102
|
-
const newCommands = controller.handle(commands);
|
|
103
|
-
|
|
104
|
-
const callback = jest.fn();
|
|
105
|
-
newCommands[0].close.subscribe(callback);
|
|
106
|
-
newCommands[1].close.subscribe(callback);
|
|
107
|
-
|
|
108
|
-
commands[0].close.next(1);
|
|
109
|
-
commands[0].close.next(1);
|
|
110
|
-
commands[0].close.next(1);
|
|
111
|
-
commands[1].close.next(1);
|
|
112
|
-
commands[1].close.next(0);
|
|
113
|
-
|
|
114
|
-
scheduler.flush();
|
|
115
|
-
|
|
116
|
-
// 1 failure from commands[0], 1 success from commands[1]
|
|
117
|
-
expect(callback).toHaveBeenCalledTimes(2);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('keep non-close streams from original commands', () => {
|
|
121
|
-
const newCommands = controller.handle(commands);
|
|
122
|
-
newCommands.forEach((newCommand, i) => {
|
|
123
|
-
expect(newCommand.close).not.toBe(commands[i].close);
|
|
124
|
-
expect(newCommand.error).toBe(commands[i].error);
|
|
125
|
-
expect(newCommand.stdout).toBe(commands[i].stdout);
|
|
126
|
-
expect(newCommand.stderr).toBe(commands[i].stderr);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const getSpawnOpts = require('./get-spawn-opts');
|
|
2
|
-
|
|
3
|
-
it('sets detached mode to false for Windows platform', () => {
|
|
4
|
-
expect(getSpawnOpts({ process: { platform: 'win32' } }).detached).toBe(false);
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
it('sets stdio to inherit when raw', () => {
|
|
8
|
-
expect(getSpawnOpts({ raw: true }).stdio).toBe('inherit');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('merges FORCE_COLOR into env vars if color supported', () => {
|
|
12
|
-
const process = { env: { foo: 'bar' } };
|
|
13
|
-
expect(getSpawnOpts({ process, colorSupport: false }).env).toBeUndefined();
|
|
14
|
-
expect(getSpawnOpts({ process, colorSupport: { level: 1 } }).env).toEqual({
|
|
15
|
-
FORCE_COLOR: 1,
|
|
16
|
-
foo: 'bar'
|
|
17
|
-
});
|
|
18
|
-
});
|
package/src/logger.spec.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
const { Writable } = require('stream');
|
|
2
|
-
const chalk = require('chalk');
|
|
3
|
-
const { createMockInstance } = require('jest-create-mock-instance');
|
|
4
|
-
const Logger = require('./logger');
|
|
5
|
-
|
|
6
|
-
let outputStream;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
outputStream = createMockInstance(Writable);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
const createLogger = options => {
|
|
12
|
-
const logger = new Logger(Object.assign({ outputStream }, options));
|
|
13
|
-
jest.spyOn(logger, 'log');
|
|
14
|
-
return logger;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
describe('#log()', () => {
|
|
18
|
-
it('writes prefix + text to the output stream', () => {
|
|
19
|
-
const logger = new Logger({ outputStream });
|
|
20
|
-
logger.log('foo', 'bar');
|
|
21
|
-
|
|
22
|
-
expect(outputStream.write).toHaveBeenCalledTimes(2);
|
|
23
|
-
expect(outputStream.write).toHaveBeenCalledWith('foo');
|
|
24
|
-
expect(outputStream.write).toHaveBeenCalledWith('bar');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('writes multiple lines of text with prefix on each', () => {
|
|
28
|
-
const logger = new Logger({ outputStream });
|
|
29
|
-
logger.log('foo', 'bar\nbaz\n');
|
|
30
|
-
|
|
31
|
-
expect(outputStream.write).toHaveBeenCalledTimes(2);
|
|
32
|
-
expect(outputStream.write).toHaveBeenCalledWith('foo');
|
|
33
|
-
expect(outputStream.write).toHaveBeenCalledWith('bar\nfoobaz\n');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('does not prepend prefix if last call did not finish with a LF', () => {
|
|
37
|
-
const logger = new Logger({ outputStream });
|
|
38
|
-
logger.log('foo', 'bar');
|
|
39
|
-
outputStream.write.mockClear();
|
|
40
|
-
logger.log('foo', 'baz');
|
|
41
|
-
|
|
42
|
-
expect(outputStream.write).toHaveBeenCalledTimes(1);
|
|
43
|
-
expect(outputStream.write).toHaveBeenCalledWith('baz');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('does not prepend prefix or handle text if logger is in raw mode', () => {
|
|
47
|
-
const logger = new Logger({ outputStream, raw: true });
|
|
48
|
-
logger.log('foo', 'bar\nbaz\n');
|
|
49
|
-
|
|
50
|
-
expect(outputStream.write).toHaveBeenCalledTimes(1);
|
|
51
|
-
expect(outputStream.write).toHaveBeenCalledWith('bar\nbaz\n');
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe('#logGlobalEvent()', () => {
|
|
56
|
-
it('does nothing if in raw mode', () => {
|
|
57
|
-
const logger = createLogger({ raw: true });
|
|
58
|
-
logger.logGlobalEvent('foo');
|
|
59
|
-
|
|
60
|
-
expect(logger.log).not.toHaveBeenCalled();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('logs in gray dim style with arrow prefix', () => {
|
|
64
|
-
const logger = createLogger();
|
|
65
|
-
logger.logGlobalEvent('foo');
|
|
66
|
-
|
|
67
|
-
expect(logger.log).toHaveBeenCalledWith(
|
|
68
|
-
chalk.gray.dim('-->') + ' ',
|
|
69
|
-
chalk.gray.dim('foo') + '\n'
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe('#logCommandText()', () => {
|
|
75
|
-
it('logs with name if no prefixFormat is set', () => {
|
|
76
|
-
const logger = createLogger();
|
|
77
|
-
logger.logCommandText('foo', { name: 'bla' });
|
|
78
|
-
|
|
79
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim('[bla]') + ' ', 'foo');
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('logs with index if no prefixFormat is set, and command has no name', () => {
|
|
83
|
-
const logger = createLogger();
|
|
84
|
-
logger.logCommandText('foo', { index: 2 });
|
|
85
|
-
|
|
86
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim('[2]') + ' ', 'foo');
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('logs with prefixFormat set to pid', () => {
|
|
90
|
-
const logger = createLogger({ prefixFormat: 'pid' });
|
|
91
|
-
logger.logCommandText('foo', {
|
|
92
|
-
pid: 123,
|
|
93
|
-
info: {}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim('[123]') + ' ', 'foo');
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('logs with prefixFormat set to name', () => {
|
|
100
|
-
const logger = createLogger({ prefixFormat: 'name' });
|
|
101
|
-
logger.logCommandText('foo', { name: 'bar' });
|
|
102
|
-
|
|
103
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim('[bar]') + ' ', 'foo');
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('logs with prefixFormat set to index', () => {
|
|
107
|
-
const logger = createLogger({ prefixFormat: 'index' });
|
|
108
|
-
logger.logCommandText('foo', { index: 3 });
|
|
109
|
-
|
|
110
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim('[3]') + ' ', 'foo');
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('logs with prefixFormat set to time (with timestampFormat)', () => {
|
|
114
|
-
const logger = createLogger({ prefixFormat: 'time', timestampFormat: 'YYYY' });
|
|
115
|
-
logger.logCommandText('foo', {});
|
|
116
|
-
|
|
117
|
-
const year = new Date().getFullYear();
|
|
118
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim(`[${year}]`) + ' ', 'foo');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('logs with templated prefixFormat', () => {
|
|
122
|
-
const logger = createLogger({ prefixFormat: '{index}-{name}' });
|
|
123
|
-
logger.logCommandText('foo', { index: 0, name: 'bar' });
|
|
124
|
-
|
|
125
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim('0-bar') + ' ', 'foo');
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('logs with no prefix', () => {
|
|
129
|
-
const logger = createLogger({ prefixFormat: 'none' });
|
|
130
|
-
logger.logCommandText('foo', { command: 'echo foo' });
|
|
131
|
-
|
|
132
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim(''), 'foo');
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('logs prefix using command line itself', () => {
|
|
136
|
-
const logger = createLogger({ prefixFormat: 'command' });
|
|
137
|
-
logger.logCommandText('foo', { command: 'echo foo' });
|
|
138
|
-
|
|
139
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim('[echo foo]') + ' ', 'foo');
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('logs prefix using command line itself, capped at prefixLength bytes', () => {
|
|
143
|
-
const logger = createLogger({ prefixFormat: 'command', prefixLength: 6 });
|
|
144
|
-
logger.logCommandText('foo', { command: 'echo foo' });
|
|
145
|
-
|
|
146
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim('[ec..oo]') + ' ', 'foo');
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('logs prefix using prefixColor from command', () => {
|
|
150
|
-
const logger = createLogger();
|
|
151
|
-
logger.logCommandText('foo', { prefixColor: 'blue', index: 1 });
|
|
152
|
-
|
|
153
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.blue('[1]') + ' ', 'foo');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('logs prefix in gray dim if prefixColor from command does not exist', () => {
|
|
157
|
-
const logger = createLogger();
|
|
158
|
-
logger.logCommandText('foo', { prefixColor: 'blue.fake', index: 1 });
|
|
159
|
-
|
|
160
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim('[1]') + ' ', 'foo');
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
describe('#logCommandEvent()', () => {
|
|
165
|
-
it('does nothing if in raw mode', () => {
|
|
166
|
-
const logger = createLogger({ raw: true });
|
|
167
|
-
logger.logCommandEvent('foo');
|
|
168
|
-
|
|
169
|
-
expect(logger.log).not.toHaveBeenCalled();
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('logs text in gray dim', () => {
|
|
173
|
-
const logger = createLogger();
|
|
174
|
-
logger.logCommandEvent('foo', { index: 1 });
|
|
175
|
-
|
|
176
|
-
expect(logger.log).toHaveBeenCalledWith(chalk.gray.dim('[1]') + ' ', chalk.gray.dim('foo') + '\n');
|
|
177
|
-
});
|
|
178
|
-
});
|