UNPKG

2.6 kBJavaScriptView Raw
1const InputHandler = require('./src/flow-control/input-handler');
2const KillOnSignal = require('./src/flow-control/kill-on-signal');
3const KillOthers = require('./src/flow-control/kill-others');
4const LogError = require('./src/flow-control/log-error');
5const LogExit = require('./src/flow-control/log-exit');
6const LogOutput = require('./src/flow-control/log-output');
7const RestartProcess = require('./src/flow-control/restart-process');
8
9const concurrently = require('./src/concurrently');
10const Logger = require('./src/logger');
11const LogTimings = require( './src/flow-control/log-timings' );
12
13module.exports = exports = (commands, options = {}) => {
14 const logger = new Logger({
15 hide: options.hide,
16 outputStream: options.outputStream || process.stdout,
17 prefixFormat: options.prefix,
18 prefixLength: options.prefixLength,
19 raw: options.raw,
20 timestampFormat: options.timestampFormat,
21 });
22
23 return concurrently(commands, {
24 maxProcesses: options.maxProcesses,
25 raw: options.raw,
26 successCondition: options.successCondition,
27 cwd: options.cwd,
28 controllers: [
29 new LogError({ logger }),
30 new LogOutput({ logger }),
31 new LogExit({ logger }),
32 new InputHandler({
33 logger,
34 defaultInputTarget: options.defaultInputTarget,
35 inputStream: options.inputStream || (options.handleInput && process.stdin),
36 pauseInputStreamOnFinish: options.pauseInputStreamOnFinish,
37 }),
38 new KillOnSignal({ process }),
39 new RestartProcess({
40 logger,
41 delay: options.restartDelay,
42 tries: options.restartTries,
43 }),
44 new KillOthers({
45 logger,
46 conditions: options.killOthers
47 }),
48 new LogTimings({
49 logger: options.timings ? logger: null,
50 timestampFormat: options.timestampFormat,
51 })
52 ],
53 prefixColors: options.prefixColors || [],
54 timings: options.timings
55 });
56};
57
58// Export all flow controllers and the main concurrently function,
59// so that 3rd-parties can use them however they want
60exports.concurrently = concurrently;
61exports.Logger = Logger;
62exports.InputHandler = InputHandler;
63exports.KillOnSignal = KillOnSignal;
64exports.KillOthers = KillOthers;
65exports.LogError = LogError;
66exports.LogExit = LogExit;
67exports.LogOutput = LogOutput;
68exports.RestartProcess = RestartProcess;
69exports.LogTimings = LogTimings;