concurrently 6.2.2 → 6.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 +3 -0
- package/bin/concurrently.js +6 -12
- package/index.js +2 -1
- package/package.json +1 -1
- package/src/concurrently.js +22 -15
- package/src/concurrently.spec.js +13 -0
package/README.md
CHANGED
|
@@ -250,6 +250,9 @@ concurrently can be used programmatically by using the API documented below:
|
|
|
250
250
|
- `prefix`: the prefix type to use when logging processes output.
|
|
251
251
|
Possible values: `index`, `pid`, `time`, `command`, `name`, `none`, or a template (eg `[{time} process: {pid}]`).
|
|
252
252
|
Default: the name of the process, or its index if no name is set.
|
|
253
|
+
- `prefixColors`: a list of colors as supported by [chalk](https://www.npmjs.com/package/chalk).
|
|
254
|
+
If concurrently would run more commands than there are colors, the last color is repeated.
|
|
255
|
+
Prefix colors specified per-command take precedence over this list.
|
|
253
256
|
- `prefixLength`: how many characters to show when prefixing with `command`. Default: `10`
|
|
254
257
|
- `raw`: whether raw mode should be used, meaning strictly process output will
|
|
255
258
|
be logged, without any prefixes, colouring or extra stuff.
|
package/bin/concurrently.js
CHANGED
|
@@ -144,19 +144,12 @@ const args = yargs
|
|
|
144
144
|
.epilogue(fs.readFileSync(__dirname + '/epilogue.txt', { encoding: 'utf8' }))
|
|
145
145
|
.argv;
|
|
146
146
|
|
|
147
|
-
const prefixColors = args.prefixColors.split(',');
|
|
148
147
|
const names = (args.names || '').split(args.nameSeparator);
|
|
149
148
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return {
|
|
155
|
-
command,
|
|
156
|
-
prefixColor: lastColor,
|
|
157
|
-
name: names[index]
|
|
158
|
-
};
|
|
159
|
-
}), {
|
|
149
|
+
concurrently(args._.map((command, index) => ({
|
|
150
|
+
command,
|
|
151
|
+
name: names[index]
|
|
152
|
+
})), {
|
|
160
153
|
handleInput: args.handleInput,
|
|
161
154
|
defaultInputTarget: args.defaultInputTarget,
|
|
162
155
|
killOthers: args.killOthers
|
|
@@ -165,11 +158,12 @@ concurrently(args._.map((command, index) => {
|
|
|
165
158
|
maxProcesses: args.maxProcesses,
|
|
166
159
|
raw: args.raw,
|
|
167
160
|
prefix: args.prefix,
|
|
161
|
+
prefixColors: args.prefixColors.split(','),
|
|
168
162
|
prefixLength: args.prefixLength,
|
|
169
163
|
restartDelay: args.restartAfter,
|
|
170
164
|
restartTries: args.restartTries,
|
|
171
165
|
successCondition: args.success,
|
|
172
|
-
timestampFormat: args.timestampFormat
|
|
166
|
+
timestampFormat: args.timestampFormat,
|
|
173
167
|
}).then(
|
|
174
168
|
() => process.exit(0),
|
|
175
169
|
() => process.exit(1)
|
package/index.js
CHANGED
package/package.json
CHANGED
package/src/concurrently.js
CHANGED
|
@@ -32,21 +32,27 @@ module.exports = (commands, options) => {
|
|
|
32
32
|
new ExpandNpmWildcard()
|
|
33
33
|
];
|
|
34
34
|
|
|
35
|
+
let lastColor = '';
|
|
35
36
|
commands = _(commands)
|
|
36
37
|
.map(mapToCommandInfo)
|
|
37
38
|
.flatMap(command => parseCommand(command, commandParsers))
|
|
38
|
-
.map((command, index) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
.map((command, index) => {
|
|
40
|
+
// Use documented behaviour of repeating last color when specifying more commands than colors
|
|
41
|
+
lastColor = options.prefixColors && options.prefixColors[index] || lastColor;
|
|
42
|
+
return new Command(
|
|
43
|
+
Object.assign({
|
|
44
|
+
index,
|
|
45
|
+
spawnOpts: getSpawnOpts({
|
|
46
|
+
raw: options.raw,
|
|
47
|
+
env: command.env,
|
|
48
|
+
cwd: command.cwd || options.cwd,
|
|
49
|
+
}),
|
|
50
|
+
prefixColor: lastColor,
|
|
51
|
+
killProcess: options.kill,
|
|
52
|
+
spawn: options.spawn,
|
|
53
|
+
}, command)
|
|
54
|
+
);
|
|
55
|
+
})
|
|
50
56
|
.value();
|
|
51
57
|
|
|
52
58
|
const handleResult = options.controllers.reduce(
|
|
@@ -75,13 +81,14 @@ module.exports = (commands, options) => {
|
|
|
75
81
|
};
|
|
76
82
|
|
|
77
83
|
function mapToCommandInfo(command) {
|
|
78
|
-
return {
|
|
84
|
+
return Object.assign({
|
|
79
85
|
command: command.command || command,
|
|
80
86
|
name: command.name || '',
|
|
81
|
-
prefixColor: command.prefixColor || '',
|
|
82
87
|
env: command.env || {},
|
|
83
88
|
cwd: command.cwd || '',
|
|
84
|
-
}
|
|
89
|
+
}, command.prefixColor ? {
|
|
90
|
+
prefixColor: command.prefixColor,
|
|
91
|
+
} : {});
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
function parseCommand(command, parsers) {
|
package/src/concurrently.spec.js
CHANGED
|
@@ -84,6 +84,19 @@ it('runs commands with a name or prefix color', () => {
|
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
it('runs commands with a list of colors', () => {
|
|
88
|
+
create(['echo', 'kill'], {
|
|
89
|
+
prefixColors: ['red']
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
controllers.forEach(controller => {
|
|
93
|
+
expect(controller.handle).toHaveBeenCalledWith([
|
|
94
|
+
expect.objectContaining({ command: 'echo', prefixColor: 'red' }),
|
|
95
|
+
expect.objectContaining({ command: 'kill', prefixColor: 'red' }),
|
|
96
|
+
]);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
87
100
|
it('passes commands wrapped from a controller to the next one', () => {
|
|
88
101
|
const fakeCommand = createFakeCommand('banana', 'banana');
|
|
89
102
|
controllers[0].handle.mockReturnValue({ commands: [fakeCommand] });
|