concurrently 6.5.0 → 7.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.
Files changed (82) hide show
  1. package/README.md +82 -22
  2. package/dist/bin/concurrently.d.ts +2 -0
  3. package/dist/bin/concurrently.js +193 -0
  4. package/dist/bin/epilogue.d.ts +1 -0
  5. package/dist/bin/epilogue.js +69 -0
  6. package/dist/src/command-parser/command-parser.d.ts +19 -0
  7. package/dist/src/command-parser/command-parser.js +2 -0
  8. package/dist/src/command-parser/expand-npm-shortcut.d.ts +8 -0
  9. package/{src → dist/src}/command-parser/expand-npm-shortcut.js +10 -3
  10. package/dist/src/command-parser/expand-npm-wildcard.d.ts +13 -0
  11. package/dist/src/command-parser/expand-npm-wildcard.js +82 -0
  12. package/dist/src/command-parser/strip-quotes.d.ts +10 -0
  13. package/{src → dist/src}/command-parser/strip-quotes.js +10 -4
  14. package/dist/src/command.d.ts +101 -0
  15. package/{src → dist/src}/command.js +53 -29
  16. package/dist/src/completion-listener.d.ts +37 -0
  17. package/dist/src/completion-listener.js +60 -0
  18. package/dist/src/concurrently.d.ts +77 -0
  19. package/dist/src/concurrently.js +120 -0
  20. package/dist/src/defaults.d.ts +52 -0
  21. package/dist/src/defaults.js +58 -0
  22. package/dist/src/flow-control/flow-controller.d.ts +13 -0
  23. package/dist/src/flow-control/flow-controller.js +2 -0
  24. package/dist/src/flow-control/input-handler.d.ts +33 -0
  25. package/dist/src/flow-control/input-handler.js +73 -0
  26. package/dist/src/flow-control/kill-on-signal.d.ts +17 -0
  27. package/{src → dist/src}/flow-control/kill-on-signal.js +13 -11
  28. package/dist/src/flow-control/kill-others.d.ts +18 -0
  29. package/dist/src/flow-control/kill-others.js +35 -0
  30. package/dist/src/flow-control/log-error.d.ts +15 -0
  31. package/dist/src/flow-control/log-error.js +21 -0
  32. package/dist/src/flow-control/log-exit.d.ts +15 -0
  33. package/dist/src/flow-control/log-exit.js +19 -0
  34. package/dist/src/flow-control/log-output.d.ts +15 -0
  35. package/{src → dist/src}/flow-control/log-output.js +13 -5
  36. package/dist/src/flow-control/log-timings.d.ts +27 -0
  37. package/dist/src/flow-control/log-timings.js +88 -0
  38. package/dist/src/flow-control/restart-process.d.ts +22 -0
  39. package/dist/src/flow-control/restart-process.js +71 -0
  40. package/dist/src/get-spawn-opts.d.ts +30 -0
  41. package/dist/src/get-spawn-opts.js +11 -0
  42. package/dist/src/index.d.ts +69 -0
  43. package/dist/src/index.js +69 -0
  44. package/dist/src/logger.d.ts +72 -0
  45. package/{src → dist/src}/logger.js +77 -58
  46. package/dist/src/output-writer.d.ts +19 -0
  47. package/dist/src/output-writer.js +69 -0
  48. package/index.js +6 -68
  49. package/index.mjs +9 -0
  50. package/package.json +38 -11
  51. package/bin/concurrently.js +0 -186
  52. package/bin/concurrently.spec.js +0 -428
  53. package/bin/epilogue.txt +0 -46
  54. package/src/command-parser/expand-npm-shortcut.spec.js +0 -36
  55. package/src/command-parser/expand-npm-wildcard.js +0 -43
  56. package/src/command-parser/expand-npm-wildcard.spec.js +0 -87
  57. package/src/command-parser/strip-quotes.spec.js +0 -20
  58. package/src/command.spec.js +0 -275
  59. package/src/completion-listener.js +0 -39
  60. package/src/completion-listener.spec.js +0 -89
  61. package/src/concurrently.js +0 -116
  62. package/src/concurrently.spec.js +0 -199
  63. package/src/defaults.js +0 -35
  64. package/src/flow-control/base-handler.js +0 -16
  65. package/src/flow-control/base-handler.spec.js +0 -22
  66. package/src/flow-control/input-handler.js +0 -50
  67. package/src/flow-control/input-handler.spec.js +0 -113
  68. package/src/flow-control/kill-on-signal.spec.js +0 -79
  69. package/src/flow-control/kill-others.js +0 -38
  70. package/src/flow-control/kill-others.spec.js +0 -66
  71. package/src/flow-control/log-error.js +0 -18
  72. package/src/flow-control/log-error.spec.js +0 -40
  73. package/src/flow-control/log-exit.js +0 -11
  74. package/src/flow-control/log-exit.spec.js +0 -36
  75. package/src/flow-control/log-output.spec.js +0 -41
  76. package/src/flow-control/log-timings.js +0 -64
  77. package/src/flow-control/log-timings.spec.js +0 -137
  78. package/src/flow-control/restart-process.js +0 -56
  79. package/src/flow-control/restart-process.spec.js +0 -139
  80. package/src/get-spawn-opts.js +0 -16
  81. package/src/get-spawn-opts.spec.js +0 -30
  82. package/src/logger.spec.js +0 -318
@@ -1,11 +0,0 @@
1
- const BaseHandler = require('./base-handler');
2
-
3
- module.exports = class LogExit extends BaseHandler {
4
- handle(commands) {
5
- commands.forEach(command => command.close.subscribe(({ exitCode }) => {
6
- this.logger.logCommandEvent(`${command.command} exited with code ${exitCode}`, command);
7
- }));
8
-
9
- return { commands };
10
- }
11
- };
@@ -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)).toMatchObject({ commands });
19
- });
20
-
21
- it('logs the close event of each command', () => {
22
- controller.handle(commands);
23
-
24
- commands[0].close.next({ exitCode: 0 });
25
- commands[1].close.next({ exitCode: '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)).toMatchObject({ 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,64 +0,0 @@
1
- const formatDate = require('date-fns/format');
2
- const Rx = require('rxjs');
3
- const { bufferCount, take } = require('rxjs/operators');
4
- const _ = require('lodash');
5
- const BaseHandler = require('./base-handler');
6
-
7
- module.exports = class LogTimings extends BaseHandler {
8
- constructor({ logger, timestampFormat }) {
9
- super({ logger });
10
-
11
- this.timestampFormat = timestampFormat;
12
- }
13
-
14
- printExitInfoTimingTable(exitInfos) {
15
- const exitInfoTable = _(exitInfos)
16
- .sortBy(({ timings }) => timings.durationSeconds)
17
- .reverse()
18
- .map(({ command, timings, killed, exitCode }) => {
19
- const readableDurationMs = (timings.endDate - timings.startDate).toLocaleString();
20
- return {
21
- name: command.name,
22
- duration: `${readableDurationMs}ms`,
23
- 'exit code': exitCode,
24
- killed,
25
- command: command.command,
26
- };
27
- })
28
- .value();
29
-
30
- this.logger.logGlobalEvent('Timings:');
31
- this.logger.logTable(exitInfoTable);
32
- return exitInfos;
33
- };
34
-
35
- handle(commands) {
36
- if (!this.logger) {
37
- return { commands };
38
- }
39
-
40
- // individual process timings
41
- commands.forEach(command => {
42
- command.timer.subscribe(({ startDate, endDate }) => {
43
- if (!endDate) {
44
- const formattedStartDate = formatDate(startDate, this.timestampFormat);
45
- this.logger.logCommandEvent(`${command.command} started at ${formattedStartDate}`, command);
46
- } else {
47
- const durationMs = endDate.getTime() - startDate.getTime();
48
- const formattedEndDate = formatDate(endDate, this.timestampFormat);
49
- this.logger.logCommandEvent(`${command.command} stopped at ${formattedEndDate} after ${durationMs.toLocaleString()}ms`, command);
50
- }
51
- });
52
- });
53
-
54
- // overall summary timings
55
- const closeStreams = commands.map(command => command.close);
56
- this.allProcessesClosed = Rx.merge(...closeStreams).pipe(
57
- bufferCount(closeStreams.length),
58
- take(1),
59
- );
60
- this.allProcessesClosed.subscribe((exitInfos) => this.printExitInfoTimingTable(exitInfos));
61
-
62
- return { commands };
63
- }
64
- };
@@ -1,137 +0,0 @@
1
- const { createMockInstance } = require('jest-create-mock-instance');
2
- const formatDate = require('date-fns/format');
3
- const Logger = require('../logger');
4
- const LogTimings = require( './log-timings' );
5
- const createFakeCommand = require('./fixtures/fake-command');
6
-
7
- // shown in timing order
8
- const startDate0 = new Date();
9
- const startDate1 = new Date(startDate0.getTime() + 1000);
10
- const endDate1 = new Date(startDate0.getTime() + 3000);
11
- const endDate0 = new Date(startDate0.getTime() + 5000);
12
-
13
- const timestampFormat = 'yyyy-MM-dd HH:mm:ss.SSS';
14
- const getDurationText = (startDate, endDate) => `${(endDate.getTime() - startDate.getTime()).toLocaleString()}ms`;
15
- const command0DurationTextMs = getDurationText(startDate0, endDate0);
16
- const command1DurationTextMs = getDurationText(startDate1, endDate1);
17
-
18
- const exitInfoToTimingInfo = ({ command, timings, killed, exitCode }) => {
19
- const readableDurationMs = getDurationText(timings.startDate, timings.endDate);
20
- return {
21
- name: command.name,
22
- duration: readableDurationMs,
23
- 'exit code': exitCode,
24
- killed,
25
- command: command.command,
26
- };
27
- };
28
-
29
- let controller, logger, commands, command0ExitInfo, command1ExitInfo;
30
-
31
- beforeEach(() => {
32
- commands = [
33
- createFakeCommand('foo', 'command 1', 0),
34
- createFakeCommand('bar', 'command 2', 1),
35
- ];
36
-
37
- command0ExitInfo = {
38
- command: commands[0].command,
39
- timings: {
40
- startDate: startDate0,
41
- endDate: endDate0,
42
- },
43
- index: commands[0].index,
44
- killed: false,
45
- exitCode: 0,
46
- };
47
-
48
- command1ExitInfo = {
49
- command: commands[1].command,
50
- timings: {
51
- startDate: startDate1,
52
- endDate: endDate1,
53
- },
54
- index: commands[1].index,
55
- killed: false,
56
- exitCode: 0,
57
- };
58
-
59
- logger = createMockInstance(Logger);
60
- controller = new LogTimings({ logger, timestampFormat });
61
- });
62
-
63
- it('returns same commands', () => {
64
- expect(controller.handle(commands)).toMatchObject({ commands });
65
- });
66
-
67
- it('does not log timings and doesn\'t throw if no logger is provided', () => {
68
- controller = new LogTimings({ });
69
- controller.handle(commands);
70
-
71
- commands[0].timer.next({ startDate: startDate0 });
72
- commands[1].timer.next({ startDate: startDate1 });
73
- commands[1].timer.next({ startDate: startDate1, endDate: endDate1 });
74
- commands[0].timer.next({ startDate: startDate0, endDate: endDate0 });
75
-
76
- expect(logger.logCommandEvent).toHaveBeenCalledTimes(0);
77
- });
78
-
79
- it('logs the timings at the start and end (ie complete or error) event of each command', () => {
80
- controller.handle(commands);
81
-
82
- commands[0].timer.next({ startDate: startDate0 });
83
- commands[1].timer.next({ startDate: startDate1 });
84
- commands[1].timer.next({ startDate: startDate1, endDate: endDate1 });
85
- commands[0].timer.next({ startDate: startDate0, endDate: endDate0 });
86
-
87
- expect(logger.logCommandEvent).toHaveBeenCalledTimes(4);
88
- expect(logger.logCommandEvent).toHaveBeenCalledWith(
89
- `${commands[0].command} started at ${formatDate(startDate0, timestampFormat)}`,
90
- commands[0]
91
- );
92
- expect(logger.logCommandEvent).toHaveBeenCalledWith(
93
- `${commands[1].command} started at ${formatDate(startDate1, timestampFormat)}`,
94
- commands[1]
95
- );
96
- expect(logger.logCommandEvent).toHaveBeenCalledWith(
97
- `${commands[1].command} stopped at ${formatDate(endDate1, timestampFormat)} after ${command1DurationTextMs}`,
98
- commands[1]
99
- );
100
- expect(logger.logCommandEvent).toHaveBeenCalledWith(
101
- `${commands[0].command} stopped at ${formatDate(endDate0, timestampFormat)} after ${command0DurationTextMs}`,
102
- commands[0]
103
- );
104
- });
105
-
106
- it('does not log timings summary if there was an error', () => {
107
- controller.handle(commands);
108
-
109
- commands[0].close.next(command0ExitInfo);
110
- commands[1].error.next();
111
-
112
- expect(logger.logTable).toHaveBeenCalledTimes(0);
113
-
114
- });
115
-
116
- it('logs the sorted timings summary when all processes close successfully', () => {
117
- jest.spyOn(controller, 'printExitInfoTimingTable');
118
- controller.handle(commands);
119
-
120
- commands[0].close.next(command0ExitInfo);
121
- commands[1].close.next(command1ExitInfo);
122
-
123
- expect(logger.logTable).toHaveBeenCalledTimes(1);
124
-
125
- // un-sorted ie by finish order
126
- expect(controller.printExitInfoTimingTable).toHaveBeenCalledWith([
127
- command0ExitInfo,
128
- command1ExitInfo
129
- ]);
130
-
131
- // sorted by duration
132
- expect(logger.logTable).toHaveBeenCalledWith([
133
- exitInfoToTimingInfo(command1ExitInfo),
134
- exitInfoToTimingInfo(command0ExitInfo)
135
- ]);
136
-
137
- });
@@ -1,56 +0,0 @@
1
- const Rx = require('rxjs');
2
- const { defaultIfEmpty, delay, filter, mapTo, skip, take, takeWhile } = require('rxjs/operators');
3
-
4
- const defaults = require('../defaults');
5
- const BaseHandler = require('./base-handler');
6
-
7
- module.exports = class RestartProcess extends BaseHandler {
8
- constructor({ delay, tries, logger, scheduler }) {
9
- super({ logger });
10
-
11
- this.delay = +delay || defaults.restartDelay;
12
- this.tries = +tries || defaults.restartTries;
13
- this.tries = this.tries < 0 ? Infinity : this.tries;
14
- this.scheduler = scheduler;
15
- }
16
-
17
- handle(commands) {
18
- if (this.tries === 0) {
19
- return { commands };
20
- }
21
-
22
- commands.map(command => command.close.pipe(
23
- take(this.tries),
24
- takeWhile(({ exitCode }) => exitCode !== 0)
25
- )).map((failure, index) => Rx.merge(
26
- // Delay the emission (so that the restarts happen on time),
27
- // explicitly telling the subscriber that a restart is needed
28
- failure.pipe(delay(this.delay, this.scheduler), mapTo(true)),
29
- // Skip the first N emissions (as these would be duplicates of the above),
30
- // meaning it will be empty because of success, or failed all N times,
31
- // and no more restarts should be attempted.
32
- failure.pipe(skip(this.tries), defaultIfEmpty(false))
33
- ).subscribe(restart => {
34
- const command = commands[index];
35
- if (restart) {
36
- this.logger.logCommandEvent(`${command.command} restarted`, command);
37
- command.start();
38
- }
39
- }));
40
-
41
- return {
42
- commands: commands.map(command => {
43
- const closeStream = command.close.pipe(filter(({ exitCode }, emission) => {
44
- // We let all success codes pass, and failures only after restarting won't happen again
45
- return exitCode === 0 || emission >= this.tries;
46
- }));
47
-
48
- return new Proxy(command, {
49
- get(target, prop) {
50
- return prop === 'close' ? closeStream : target[prop];
51
- }
52
- });
53
- })
54
- };
55
- }
56
- };
@@ -1,139 +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({ exitCode: 0 });
29
- commands[1].close.next({ exitCode: 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({ exitCode: 1 });
41
- commands[1].close.next({ exitCode: 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({ exitCode: 1 });
58
- commands[0].close.next({ exitCode: 'SIGTERM' });
59
- commands[0].close.next({ exitCode: 'SIGTERM' });
60
- commands[1].close.next({ exitCode: 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('restart processes forever, if tries is negative', () => {
73
- controller = new RestartProcess({
74
- logger,
75
- scheduler,
76
- delay: 100,
77
- tries: -1
78
- });
79
- expect(controller.tries).toBe(Infinity);
80
- });
81
-
82
- it('restarts processes until they succeed', () => {
83
- controller.handle(commands);
84
-
85
- commands[0].close.next({ exitCode: 1 });
86
- commands[0].close.next({ exitCode: 0 });
87
- commands[1].close.next({ exitCode: 0 });
88
-
89
- scheduler.flush();
90
-
91
- expect(logger.logCommandEvent).toHaveBeenCalledTimes(1);
92
- expect(logger.logCommandEvent).toHaveBeenCalledWith(
93
- `${commands[0].command} restarted`,
94
- commands[0]
95
- );
96
- expect(commands[0].start).toHaveBeenCalledTimes(1);
97
- });
98
-
99
- describe('returned commands', () => {
100
- it('are the same if 0 tries are to be attempted', () => {
101
- controller = new RestartProcess({ logger, scheduler });
102
- expect(controller.handle(commands)).toMatchObject({ commands });
103
- });
104
-
105
- it('are not the same, but with same length if 1+ tries are to be attempted', () => {
106
- const { commands: newCommands } = controller.handle(commands);
107
- expect(newCommands).not.toBe(commands);
108
- expect(newCommands).toHaveLength(commands.length);
109
- });
110
-
111
- it('skip close events followed by restarts', () => {
112
- const { commands: newCommands } = controller.handle(commands);
113
-
114
- const callback = jest.fn();
115
- newCommands[0].close.subscribe(callback);
116
- newCommands[1].close.subscribe(callback);
117
-
118
- commands[0].close.next({ exitCode: 1 });
119
- commands[0].close.next({ exitCode: 1 });
120
- commands[0].close.next({ exitCode: 1 });
121
- commands[1].close.next({ exitCode: 1 });
122
- commands[1].close.next({ exitCode: 0 });
123
-
124
- scheduler.flush();
125
-
126
- // 1 failure from commands[0], 1 success from commands[1]
127
- expect(callback).toHaveBeenCalledTimes(2);
128
- });
129
-
130
- it('keep non-close streams from original commands', () => {
131
- const { commands: newCommands } = controller.handle(commands);
132
- newCommands.forEach((newCommand, i) => {
133
- expect(newCommand.close).not.toBe(commands[i].close);
134
- expect(newCommand.error).toBe(commands[i].error);
135
- expect(newCommand.stdout).toBe(commands[i].stdout);
136
- expect(newCommand.stderr).toBe(commands[i].stderr);
137
- });
138
- });
139
- });
@@ -1,16 +0,0 @@
1
- const supportsColor = require('supports-color');
2
-
3
- module.exports = ({
4
- colorSupport = supportsColor.stdout,
5
- cwd,
6
- process = global.process,
7
- raw = false,
8
- env = {},
9
- }) => Object.assign(
10
- {
11
- cwd: cwd || process.cwd(),
12
- },
13
- raw && { stdio: 'inherit' },
14
- /^win/.test(process.platform) && { detached: false },
15
- { env: Object.assign(colorSupport ? { FORCE_COLOR: colorSupport.level } : {}, process.env, env) }
16
- );
@@ -1,30 +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', cwd: jest.fn() } }).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' }, cwd: jest.fn() };
13
- expect(getSpawnOpts({ process, colorSupport: false }).env).toEqual(process.env);
14
- expect(getSpawnOpts({ process, colorSupport: { level: 1 } }).env).toEqual({
15
- FORCE_COLOR: 1,
16
- foo: 'bar'
17
- });
18
- });
19
-
20
- it('sets default cwd to process.cwd()', () => {
21
- const process = { cwd: jest.fn().mockReturnValue('process-cwd') };
22
- expect(getSpawnOpts({
23
- process,
24
- }).cwd).toBe('process-cwd');
25
- });
26
-
27
- it('overrides default cwd', () => {
28
- const cwd = 'foobar';
29
- expect(getSpawnOpts({ cwd }).cwd).toBe(cwd);
30
- });