concurrently 6.3.0 → 7.0.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 +82 -35
- package/dist/bin/concurrently.d.ts +2 -0
- package/dist/bin/concurrently.js +193 -0
- package/dist/bin/concurrently.spec.d.ts +1 -0
- package/dist/bin/epilogue.d.ts +1 -0
- package/dist/bin/epilogue.js +65 -0
- package/dist/src/command-parser/command-parser.d.ts +19 -0
- package/dist/src/command-parser/command-parser.js +2 -0
- package/dist/src/command-parser/expand-npm-shortcut.d.ts +8 -0
- package/{src → dist/src}/command-parser/expand-npm-shortcut.js +10 -3
- package/dist/src/command-parser/expand-npm-shortcut.spec.d.ts +1 -0
- package/dist/src/command-parser/expand-npm-wildcard.d.ts +13 -0
- package/dist/src/command-parser/expand-npm-wildcard.js +73 -0
- package/dist/src/command-parser/expand-npm-wildcard.spec.d.ts +1 -0
- package/dist/src/command-parser/strip-quotes.d.ts +10 -0
- package/{src → dist/src}/command-parser/strip-quotes.js +10 -4
- package/dist/src/command-parser/strip-quotes.spec.d.ts +1 -0
- package/dist/src/command.d.ts +101 -0
- package/dist/src/command.js +101 -0
- package/dist/src/command.spec.d.ts +1 -0
- package/dist/src/completion-listener.d.ts +37 -0
- package/dist/src/completion-listener.js +60 -0
- package/dist/src/completion-listener.spec.d.ts +1 -0
- package/dist/src/concurrently.d.ts +77 -0
- package/dist/src/concurrently.js +120 -0
- package/dist/src/concurrently.spec.d.ts +1 -0
- package/dist/src/defaults.d.ts +52 -0
- package/dist/src/defaults.js +58 -0
- package/dist/src/flow-control/flow-controller.d.ts +13 -0
- package/dist/src/flow-control/flow-controller.js +2 -0
- package/dist/src/flow-control/input-handler.d.ts +33 -0
- package/dist/src/flow-control/input-handler.js +73 -0
- package/dist/src/flow-control/input-handler.spec.d.ts +1 -0
- package/dist/src/flow-control/kill-on-signal.d.ts +17 -0
- package/{src → dist/src}/flow-control/kill-on-signal.js +13 -11
- package/dist/src/flow-control/kill-on-signal.spec.d.ts +1 -0
- package/dist/src/flow-control/kill-others.d.ts +18 -0
- package/dist/src/flow-control/kill-others.js +35 -0
- package/dist/src/flow-control/kill-others.spec.d.ts +1 -0
- package/dist/src/flow-control/log-error.d.ts +15 -0
- package/dist/src/flow-control/log-error.js +21 -0
- package/dist/src/flow-control/log-error.spec.d.ts +1 -0
- package/dist/src/flow-control/log-exit.d.ts +15 -0
- package/dist/src/flow-control/log-exit.js +19 -0
- package/dist/src/flow-control/log-exit.spec.d.ts +1 -0
- package/dist/src/flow-control/log-output.d.ts +15 -0
- package/{src → dist/src}/flow-control/log-output.js +13 -5
- package/dist/src/flow-control/log-output.spec.d.ts +1 -0
- package/dist/src/flow-control/log-timings.d.ts +27 -0
- package/dist/src/flow-control/log-timings.js +88 -0
- package/dist/src/flow-control/log-timings.spec.d.ts +1 -0
- package/dist/src/flow-control/restart-process.d.ts +22 -0
- package/dist/src/flow-control/restart-process.js +71 -0
- package/dist/src/flow-control/restart-process.spec.d.ts +1 -0
- package/dist/src/get-spawn-opts.d.ts +30 -0
- package/dist/src/get-spawn-opts.js +11 -0
- package/dist/src/get-spawn-opts.spec.d.ts +1 -0
- package/dist/src/index.d.ts +69 -0
- package/dist/src/index.js +69 -0
- package/dist/src/logger.d.ts +72 -0
- package/dist/src/logger.js +199 -0
- package/dist/src/logger.spec.d.ts +1 -0
- package/dist/src/output-writer.d.ts +19 -0
- package/dist/src/output-writer.js +69 -0
- package/dist/src/output-writer.spec.d.ts +1 -0
- package/index.js +6 -60
- package/index.mjs +9 -0
- package/package.json +37 -11
- package/bin/concurrently.js +0 -170
- package/bin/concurrently.spec.js +0 -365
- package/bin/epilogue.txt +0 -42
- package/src/command-parser/expand-npm-shortcut.spec.js +0 -36
- package/src/command-parser/expand-npm-wildcard.js +0 -43
- package/src/command-parser/expand-npm-wildcard.spec.js +0 -58
- package/src/command-parser/strip-quotes.spec.js +0 -20
- package/src/command.js +0 -63
- package/src/command.spec.js +0 -183
- package/src/completion-listener.js +0 -39
- package/src/completion-listener.spec.js +0 -88
- package/src/concurrently.js +0 -111
- package/src/concurrently.spec.js +0 -199
- package/src/defaults.js +0 -31
- package/src/flow-control/base-handler.js +0 -16
- package/src/flow-control/input-handler.js +0 -50
- package/src/flow-control/input-handler.spec.js +0 -113
- package/src/flow-control/kill-on-signal.spec.js +0 -79
- package/src/flow-control/kill-others.js +0 -38
- package/src/flow-control/kill-others.spec.js +0 -66
- package/src/flow-control/log-error.js +0 -18
- package/src/flow-control/log-error.spec.js +0 -40
- package/src/flow-control/log-exit.js +0 -11
- 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.js +0 -56
- package/src/flow-control/restart-process.spec.js +0 -131
- package/src/get-spawn-opts.js +0 -16
- package/src/get-spawn-opts.spec.js +0 -30
- package/src/logger.js +0 -115
- package/src/logger.spec.js +0 -195
package/bin/concurrently.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const yargs = require('yargs');
|
|
4
|
-
const defaults = require('../src/defaults');
|
|
5
|
-
const concurrently = require('../index');
|
|
6
|
-
|
|
7
|
-
const args = yargs
|
|
8
|
-
.usage('$0 [options] <command ...>')
|
|
9
|
-
.help('h')
|
|
10
|
-
.alias('h', 'help')
|
|
11
|
-
.version('v', require('../package.json').version)
|
|
12
|
-
.alias('v', 'V')
|
|
13
|
-
.alias('v', 'version')
|
|
14
|
-
.options({
|
|
15
|
-
// General
|
|
16
|
-
'm': {
|
|
17
|
-
alias: 'max-processes',
|
|
18
|
-
describe:
|
|
19
|
-
'How many processes should run at once.\n' +
|
|
20
|
-
'New processes only spawn after all restart tries of a process.',
|
|
21
|
-
type: 'number'
|
|
22
|
-
},
|
|
23
|
-
'n': {
|
|
24
|
-
alias: 'names',
|
|
25
|
-
describe:
|
|
26
|
-
'List of custom names to be used in prefix template.\n' +
|
|
27
|
-
'Example names: "main,browser,server"',
|
|
28
|
-
type: 'string'
|
|
29
|
-
},
|
|
30
|
-
'name-separator': {
|
|
31
|
-
describe:
|
|
32
|
-
'The character to split <names> on. Example usage:\n' +
|
|
33
|
-
'concurrently -n "styles|scripts|server" --name-separator "|"',
|
|
34
|
-
default: defaults.nameSeparator,
|
|
35
|
-
},
|
|
36
|
-
's': {
|
|
37
|
-
alias: 'success',
|
|
38
|
-
describe:
|
|
39
|
-
'Return exit code of zero or one based on the success or failure ' +
|
|
40
|
-
'of the "first" child to terminate, the "last child", or succeed ' +
|
|
41
|
-
'only if "all" child processes succeed.',
|
|
42
|
-
choices: ['first', 'last', 'all'],
|
|
43
|
-
default: defaults.success
|
|
44
|
-
},
|
|
45
|
-
'r': {
|
|
46
|
-
alias: 'raw',
|
|
47
|
-
describe:
|
|
48
|
-
'Output only raw output of processes, disables prettifying ' +
|
|
49
|
-
'and concurrently coloring.',
|
|
50
|
-
type: 'boolean'
|
|
51
|
-
},
|
|
52
|
-
// This one is provided for free. Chalk reads this itself and removes colours.
|
|
53
|
-
// https://www.npmjs.com/package/chalk#chalksupportscolor
|
|
54
|
-
'no-color': {
|
|
55
|
-
describe: 'Disables colors from logging',
|
|
56
|
-
type: 'boolean'
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
// Kill others
|
|
60
|
-
'k': {
|
|
61
|
-
alias: 'kill-others',
|
|
62
|
-
describe: 'kill other processes if one exits or dies',
|
|
63
|
-
type: 'boolean'
|
|
64
|
-
},
|
|
65
|
-
'kill-others-on-fail': {
|
|
66
|
-
describe: 'kill other processes if one exits with non zero status code',
|
|
67
|
-
type: 'boolean'
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
// Prefix
|
|
71
|
-
'p': {
|
|
72
|
-
alias: 'prefix',
|
|
73
|
-
describe:
|
|
74
|
-
'Prefix used in logging for each process.\n' +
|
|
75
|
-
'Possible values: index, pid, time, command, name, none, or a template. ' +
|
|
76
|
-
'Example template: "{time}-{pid}"',
|
|
77
|
-
defaultDescription: 'index or name (when --names is set)',
|
|
78
|
-
type: 'string'
|
|
79
|
-
},
|
|
80
|
-
'c': {
|
|
81
|
-
alias: 'prefix-colors',
|
|
82
|
-
describe:
|
|
83
|
-
'Comma-separated list of chalk colors to use on prefixes. ' +
|
|
84
|
-
'If there are more commands than colors, the last color will be repeated.\n' +
|
|
85
|
-
'- Available modifiers: reset, bold, dim, italic, underline, inverse, hidden, strikethrough\n' +
|
|
86
|
-
'- Available colors: black, red, green, yellow, blue, magenta, cyan, white, gray \n' +
|
|
87
|
-
'or any hex values for colors, eg #23de43\n' +
|
|
88
|
-
'- Available background colors: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite\n' +
|
|
89
|
-
'See https://www.npmjs.com/package/chalk for more information.',
|
|
90
|
-
default: defaults.prefixColors,
|
|
91
|
-
type: 'string'
|
|
92
|
-
},
|
|
93
|
-
'l': {
|
|
94
|
-
alias: 'prefix-length',
|
|
95
|
-
describe:
|
|
96
|
-
'Limit how many characters of the command is displayed in prefix. ' +
|
|
97
|
-
'The option can be used to shorten the prefix when it is set to "command"',
|
|
98
|
-
default: defaults.prefixLength,
|
|
99
|
-
type: 'number'
|
|
100
|
-
},
|
|
101
|
-
't': {
|
|
102
|
-
alias: 'timestamp-format',
|
|
103
|
-
describe: 'Specify the timestamp in moment/date-fns format.',
|
|
104
|
-
default: defaults.timestampFormat,
|
|
105
|
-
type: 'string'
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
// Restarting
|
|
109
|
-
'restart-tries': {
|
|
110
|
-
describe:
|
|
111
|
-
'How many times a process that died should restart.\n' +
|
|
112
|
-
'Negative numbers will make the process restart forever.',
|
|
113
|
-
default: defaults.restartTries,
|
|
114
|
-
type: 'number'
|
|
115
|
-
},
|
|
116
|
-
'restart-after': {
|
|
117
|
-
describe: 'Delay time to respawn the process, in milliseconds.',
|
|
118
|
-
default: defaults.restartDelay,
|
|
119
|
-
type: 'number'
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
// Input
|
|
123
|
-
'i': {
|
|
124
|
-
alias: 'handle-input',
|
|
125
|
-
describe:
|
|
126
|
-
'Whether input should be forwarded to the child processes. ' +
|
|
127
|
-
'See examples for more information.',
|
|
128
|
-
type: 'boolean'
|
|
129
|
-
},
|
|
130
|
-
'default-input-target': {
|
|
131
|
-
default: defaults.defaultInputTarget,
|
|
132
|
-
describe:
|
|
133
|
-
'Identifier for child process to which input on stdin ' +
|
|
134
|
-
'should be sent if not specified at start of input.\n' +
|
|
135
|
-
'Can be either the index or the name of the process.'
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
.group(['m', 'n', 'name-separator', 'raw', 's', 'no-color'], 'General')
|
|
139
|
-
.group(['p', 'c', 'l', 't'], 'Prefix styling')
|
|
140
|
-
.group(['i', 'default-input-target'], 'Input handling')
|
|
141
|
-
.group(['k', 'kill-others-on-fail'], 'Killing other processes')
|
|
142
|
-
.group(['restart-tries', 'restart-after'], 'Restarting')
|
|
143
|
-
// Too much text to write as JS strings, .txt file is better
|
|
144
|
-
.epilogue(fs.readFileSync(__dirname + '/epilogue.txt', { encoding: 'utf8' }))
|
|
145
|
-
.argv;
|
|
146
|
-
|
|
147
|
-
const names = (args.names || '').split(args.nameSeparator);
|
|
148
|
-
|
|
149
|
-
concurrently(args._.map((command, index) => ({
|
|
150
|
-
command,
|
|
151
|
-
name: names[index]
|
|
152
|
-
})), {
|
|
153
|
-
handleInput: args.handleInput,
|
|
154
|
-
defaultInputTarget: args.defaultInputTarget,
|
|
155
|
-
killOthers: args.killOthers
|
|
156
|
-
? ['success', 'failure']
|
|
157
|
-
: (args.killOthersOnFail ? ['failure'] : []),
|
|
158
|
-
maxProcesses: args.maxProcesses,
|
|
159
|
-
raw: args.raw,
|
|
160
|
-
prefix: args.prefix,
|
|
161
|
-
prefixColors: args.prefixColors.split(','),
|
|
162
|
-
prefixLength: args.prefixLength,
|
|
163
|
-
restartDelay: args.restartAfter,
|
|
164
|
-
restartTries: args.restartTries,
|
|
165
|
-
successCondition: args.success,
|
|
166
|
-
timestampFormat: args.timestampFormat,
|
|
167
|
-
}).then(
|
|
168
|
-
() => process.exit(0),
|
|
169
|
-
() => process.exit(1)
|
|
170
|
-
);
|
package/bin/concurrently.spec.js
DELETED
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
const readline = require('readline');
|
|
2
|
-
const _ = require('lodash');
|
|
3
|
-
const Rx = require('rxjs');
|
|
4
|
-
const { buffer, map } = require('rxjs/operators');
|
|
5
|
-
const spawn = require('spawn-command');
|
|
6
|
-
|
|
7
|
-
const isWindows = process.platform === 'win32';
|
|
8
|
-
const createKillMessage = prefix => new RegExp(
|
|
9
|
-
_.escapeRegExp(prefix) +
|
|
10
|
-
' exited with code ' +
|
|
11
|
-
(isWindows ? 1 : '(SIGTERM|143)')
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const run = args => {
|
|
15
|
-
const child = spawn('node ./concurrently.js ' + args, {
|
|
16
|
-
cwd: __dirname,
|
|
17
|
-
env: Object.assign({}, process.env, {
|
|
18
|
-
// When upgrading from jest 23 -> 24, colors started printing in the test output.
|
|
19
|
-
// They are forcibly disabled here
|
|
20
|
-
FORCE_COLOR: 0
|
|
21
|
-
}),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const stdout = readline.createInterface({
|
|
25
|
-
input: child.stdout,
|
|
26
|
-
output: null
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const stderr = readline.createInterface({
|
|
30
|
-
input: child.stderr,
|
|
31
|
-
output: null
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const close = Rx.fromEvent(child, 'close');
|
|
35
|
-
const log = Rx.merge(
|
|
36
|
-
Rx.fromEvent(stdout, 'line'),
|
|
37
|
-
Rx.fromEvent(stderr, 'line')
|
|
38
|
-
).pipe(map(data => data.toString()));
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
close,
|
|
42
|
-
log,
|
|
43
|
-
stdin: child.stdin,
|
|
44
|
-
pid: child.pid
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
it('has help command', done => {
|
|
49
|
-
run('--help').close.subscribe(event => {
|
|
50
|
-
expect(event[0]).toBe(0);
|
|
51
|
-
done();
|
|
52
|
-
}, done);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('has version command', done => {
|
|
56
|
-
Rx.combineLatest(
|
|
57
|
-
run('--version').close,
|
|
58
|
-
run('-V').close,
|
|
59
|
-
run('-v').close
|
|
60
|
-
).subscribe(events => {
|
|
61
|
-
expect(events[0][0]).toBe(0);
|
|
62
|
-
expect(events[1][0]).toBe(0);
|
|
63
|
-
expect(events[2][0]).toBe(0);
|
|
64
|
-
done();
|
|
65
|
-
}, done);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('exiting conditions', () => {
|
|
69
|
-
it('is of success by default when running successful commands', done => {
|
|
70
|
-
run('"echo foo" "echo bar"')
|
|
71
|
-
.close
|
|
72
|
-
.subscribe(exit => {
|
|
73
|
-
expect(exit[0]).toBe(0);
|
|
74
|
-
done();
|
|
75
|
-
}, done);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('is of failure by default when one of the command fails', done => {
|
|
79
|
-
run('"echo foo" "exit 1"')
|
|
80
|
-
.close
|
|
81
|
-
.subscribe(exit => {
|
|
82
|
-
expect(exit[0]).toBeGreaterThan(0);
|
|
83
|
-
done();
|
|
84
|
-
}, done);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('is of success when --success=first and first command to exit succeeds', done => {
|
|
88
|
-
run('--success=first "echo foo" "sleep 0.5 && exit 1"')
|
|
89
|
-
.close
|
|
90
|
-
.subscribe(exit => {
|
|
91
|
-
expect(exit[0]).toBe(0);
|
|
92
|
-
done();
|
|
93
|
-
}, done);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('is of failure when --success=first and first command to exit fails', done => {
|
|
97
|
-
run('--success=first "exit 1" "sleep 0.5 && echo foo"')
|
|
98
|
-
.close
|
|
99
|
-
.subscribe(exit => {
|
|
100
|
-
expect(exit[0]).toBeGreaterThan(0);
|
|
101
|
-
done();
|
|
102
|
-
}, done);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('is of success when --success=last and last command to exit succeeds', done => {
|
|
106
|
-
run('--success=last "exit 1" "sleep 0.5 && echo foo"')
|
|
107
|
-
.close
|
|
108
|
-
.subscribe(exit => {
|
|
109
|
-
expect(exit[0]).toBe(0);
|
|
110
|
-
done();
|
|
111
|
-
}, done);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('is of failure when --success=last and last command to exit fails', done => {
|
|
115
|
-
run('--success=last "echo foo" "sleep 0.5 && exit 1"')
|
|
116
|
-
.close
|
|
117
|
-
.subscribe(exit => {
|
|
118
|
-
expect(exit[0]).toBeGreaterThan(0);
|
|
119
|
-
done();
|
|
120
|
-
}, done);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it.skip('is of success when a SIGINT is sent', done => {
|
|
124
|
-
const child = run('"node fixtures/read-echo.js"');
|
|
125
|
-
child.close.subscribe(exit => {
|
|
126
|
-
// TODO This is null within Node, but should be 0 outside (eg from real terminal)
|
|
127
|
-
expect(exit[0]).toBe(0);
|
|
128
|
-
done();
|
|
129
|
-
}, done);
|
|
130
|
-
|
|
131
|
-
process.kill(child.pid, 'SIGINT');
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('is aliased to -s', done => {
|
|
135
|
-
run('-s last "exit 1" "sleep 0.5 && echo foo"')
|
|
136
|
-
.close
|
|
137
|
-
.subscribe(exit => {
|
|
138
|
-
expect(exit[0]).toBe(0);
|
|
139
|
-
done();
|
|
140
|
-
}, done);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
describe('--raw', () => {
|
|
145
|
-
it('is aliased to -r', done => {
|
|
146
|
-
const child = run('-r "echo foo" "echo bar"');
|
|
147
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
148
|
-
expect(lines).toHaveLength(2);
|
|
149
|
-
expect(lines).toContainEqual(expect.stringContaining('foo'));
|
|
150
|
-
expect(lines).toContainEqual(expect.stringContaining('bar'));
|
|
151
|
-
done();
|
|
152
|
-
}, done);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it('does not log any extra output', done => {
|
|
156
|
-
const child = run('--raw "echo foo" "echo bar"');
|
|
157
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
158
|
-
expect(lines).toHaveLength(2);
|
|
159
|
-
expect(lines).toContainEqual(expect.stringContaining('foo'));
|
|
160
|
-
expect(lines).toContainEqual(expect.stringContaining('bar'));
|
|
161
|
-
done();
|
|
162
|
-
}, done);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
describe('--names', () => {
|
|
167
|
-
it('is aliased to -n', done => {
|
|
168
|
-
const child = run('-n foo,bar "echo foo" "echo bar"');
|
|
169
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
170
|
-
expect(lines).toContainEqual(expect.stringContaining('[foo] foo'));
|
|
171
|
-
expect(lines).toContainEqual(expect.stringContaining('[bar] bar'));
|
|
172
|
-
done();
|
|
173
|
-
}, done);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('prefixes with names', done => {
|
|
177
|
-
const child = run('--names foo,bar "echo foo" "echo bar"');
|
|
178
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
179
|
-
expect(lines).toContainEqual(expect.stringContaining('[foo] foo'));
|
|
180
|
-
expect(lines).toContainEqual(expect.stringContaining('[bar] bar'));
|
|
181
|
-
done();
|
|
182
|
-
}, done);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('is split using --name-separator arg', done => {
|
|
186
|
-
const child = run('--names "foo|bar" --name-separator "|" "echo foo" "echo bar"');
|
|
187
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
188
|
-
expect(lines).toContainEqual(expect.stringContaining('[foo] foo'));
|
|
189
|
-
expect(lines).toContainEqual(expect.stringContaining('[bar] bar'));
|
|
190
|
-
done();
|
|
191
|
-
}, done);
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
describe('--prefix', () => {
|
|
196
|
-
it('is aliased to -p', done => {
|
|
197
|
-
const child = run('-p command "echo foo" "echo bar"');
|
|
198
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
199
|
-
expect(lines).toContainEqual(expect.stringContaining('[echo foo] foo'));
|
|
200
|
-
expect(lines).toContainEqual(expect.stringContaining('[echo bar] bar'));
|
|
201
|
-
done();
|
|
202
|
-
}, done);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it('specifies custom prefix', done => {
|
|
206
|
-
const child = run('--prefix command "echo foo" "echo bar"');
|
|
207
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
208
|
-
expect(lines).toContainEqual(expect.stringContaining('[echo foo] foo'));
|
|
209
|
-
expect(lines).toContainEqual(expect.stringContaining('[echo bar] bar'));
|
|
210
|
-
done();
|
|
211
|
-
}, done);
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
describe('--prefix-length', () => {
|
|
216
|
-
it('is aliased to -l', done => {
|
|
217
|
-
const child = run('-p command -l 5 "echo foo" "echo bar"');
|
|
218
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
219
|
-
expect(lines).toContainEqual(expect.stringContaining('[ec..o] foo'));
|
|
220
|
-
expect(lines).toContainEqual(expect.stringContaining('[ec..r] bar'));
|
|
221
|
-
done();
|
|
222
|
-
}, done);
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it('specifies custom prefix length', done => {
|
|
226
|
-
const child = run('--prefix command --prefix-length 5 "echo foo" "echo bar"');
|
|
227
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
228
|
-
expect(lines).toContainEqual(expect.stringContaining('[ec..o] foo'));
|
|
229
|
-
expect(lines).toContainEqual(expect.stringContaining('[ec..r] bar'));
|
|
230
|
-
done();
|
|
231
|
-
}, done);
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
describe('--restart-tries', () => {
|
|
236
|
-
it('changes how many times a command will restart', done => {
|
|
237
|
-
const child = run('--restart-tries 1 "exit 1"');
|
|
238
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
239
|
-
expect(lines).toEqual([
|
|
240
|
-
expect.stringContaining('[0] exit 1 exited with code 1'),
|
|
241
|
-
expect.stringContaining('[0] exit 1 restarted'),
|
|
242
|
-
expect.stringContaining('[0] exit 1 exited with code 1'),
|
|
243
|
-
]);
|
|
244
|
-
done();
|
|
245
|
-
}, done);
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
describe('--kill-others', () => {
|
|
250
|
-
it('is aliased to -k', done => {
|
|
251
|
-
const child = run('-k "sleep 10" "exit 0"');
|
|
252
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
253
|
-
expect(lines).toContainEqual(expect.stringContaining('[1] exit 0 exited with code 0'));
|
|
254
|
-
expect(lines).toContainEqual(expect.stringContaining('Sending SIGTERM to other processes'));
|
|
255
|
-
expect(lines).toContainEqual(expect.stringMatching(createKillMessage('[0] sleep 10')));
|
|
256
|
-
done();
|
|
257
|
-
}, done);
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it('kills on success', done => {
|
|
261
|
-
const child = run('--kill-others "sleep 10" "exit 0"');
|
|
262
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
263
|
-
expect(lines).toContainEqual(expect.stringContaining('[1] exit 0 exited with code 0'));
|
|
264
|
-
expect(lines).toContainEqual(expect.stringContaining('Sending SIGTERM to other processes'));
|
|
265
|
-
expect(lines).toContainEqual(expect.stringMatching(createKillMessage('[0] sleep 10')));
|
|
266
|
-
done();
|
|
267
|
-
}, done);
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it('kills on failure', done => {
|
|
271
|
-
const child = run('--kill-others "sleep 10" "exit 1"');
|
|
272
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
273
|
-
expect(lines).toContainEqual(expect.stringContaining('[1] exit 1 exited with code 1'));
|
|
274
|
-
expect(lines).toContainEqual(expect.stringContaining('Sending SIGTERM to other processes'));
|
|
275
|
-
expect(lines).toContainEqual(expect.stringMatching(createKillMessage('[0] sleep 10')));
|
|
276
|
-
done();
|
|
277
|
-
}, done);
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
describe('--kill-others-on-fail', () => {
|
|
282
|
-
it('does not kill on success', done => {
|
|
283
|
-
const child = run('--kill-others-on-fail "sleep 0.5" "exit 0"');
|
|
284
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
285
|
-
expect(lines).toContainEqual(expect.stringContaining('[1] exit 0 exited with code 0'));
|
|
286
|
-
expect(lines).toContainEqual(expect.stringContaining('[0] sleep 0.5 exited with code 0'));
|
|
287
|
-
done();
|
|
288
|
-
}, done);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
it('kills on failure', done => {
|
|
292
|
-
const child = run('--kill-others-on-fail "sleep 10" "exit 1"');
|
|
293
|
-
child.log.pipe(buffer(child.close)).subscribe(lines => {
|
|
294
|
-
expect(lines).toContainEqual(expect.stringContaining('[1] exit 1 exited with code 1'));
|
|
295
|
-
expect(lines).toContainEqual(expect.stringContaining('Sending SIGTERM to other processes'));
|
|
296
|
-
expect(lines).toContainEqual(expect.stringMatching(createKillMessage('[0] sleep 10')));
|
|
297
|
-
done();
|
|
298
|
-
}, done);
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
describe('--handle-input', () => {
|
|
303
|
-
it('is aliased to -i', done => {
|
|
304
|
-
const child = run('-i "node fixtures/read-echo.js"');
|
|
305
|
-
child.log.subscribe(line => {
|
|
306
|
-
if (/READING/.test(line)) {
|
|
307
|
-
child.stdin.write('stop\n');
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (/\[0\] stop/.test(line)) {
|
|
311
|
-
done();
|
|
312
|
-
}
|
|
313
|
-
}, done);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
it('forwards input to first process by default', done => {
|
|
317
|
-
const child = run('--handle-input "node fixtures/read-echo.js"');
|
|
318
|
-
child.log.subscribe(line => {
|
|
319
|
-
if (/READING/.test(line)) {
|
|
320
|
-
child.stdin.write('stop\n');
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (/\[0\] stop/.test(line)) {
|
|
324
|
-
done();
|
|
325
|
-
}
|
|
326
|
-
}, done);
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
it('forwards input to process --default-input-target', done => {
|
|
331
|
-
const lines = [];
|
|
332
|
-
const child = run('-ki --default-input-target 1 "node fixtures/read-echo.js" "node fixtures/read-echo.js"');
|
|
333
|
-
child.log.subscribe(line => {
|
|
334
|
-
lines.push(line);
|
|
335
|
-
if (/\[1\] READING/.test(line)) {
|
|
336
|
-
child.stdin.write('stop\n');
|
|
337
|
-
}
|
|
338
|
-
}, done);
|
|
339
|
-
|
|
340
|
-
child.close.subscribe(exit => {
|
|
341
|
-
expect(exit[0]).toBeGreaterThan(0);
|
|
342
|
-
expect(lines).toContainEqual(expect.stringContaining('[1] stop'));
|
|
343
|
-
expect(lines).toContainEqual(expect.stringMatching(createKillMessage('[0] node fixtures/read-echo.js')));
|
|
344
|
-
done();
|
|
345
|
-
}, done);
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
it('forwards input to specified process', done => {
|
|
349
|
-
const lines = [];
|
|
350
|
-
const child = run('-ki "node fixtures/read-echo.js" "node fixtures/read-echo.js"');
|
|
351
|
-
child.log.subscribe(line => {
|
|
352
|
-
lines.push(line);
|
|
353
|
-
if (/\[1\] READING/.test(line)) {
|
|
354
|
-
child.stdin.write('1:stop\n');
|
|
355
|
-
}
|
|
356
|
-
}, done);
|
|
357
|
-
|
|
358
|
-
child.close.subscribe(exit => {
|
|
359
|
-
expect(exit[0]).toBeGreaterThan(0);
|
|
360
|
-
expect(lines).toContainEqual(expect.stringContaining('[1] stop'));
|
|
361
|
-
expect(lines).toContainEqual(expect.stringMatching(createKillMessage('[0] node fixtures/read-echo.js')));
|
|
362
|
-
done();
|
|
363
|
-
}, done);
|
|
364
|
-
});
|
|
365
|
-
});
|
package/bin/epilogue.txt
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
Examples:
|
|
2
|
-
|
|
3
|
-
- Output nothing more than stdout+stderr of child processes
|
|
4
|
-
|
|
5
|
-
$ $0 --raw "npm run watch-less" "npm run watch-js"
|
|
6
|
-
|
|
7
|
-
- Normal output but without colors e.g. when logging to file
|
|
8
|
-
|
|
9
|
-
$ $0 --no-color "grunt watch" "http-server" > log
|
|
10
|
-
|
|
11
|
-
- Custom prefix
|
|
12
|
-
|
|
13
|
-
$ $0 --prefix "{time}-{pid}" "npm run watch" "http-server"
|
|
14
|
-
|
|
15
|
-
- Custom names and colored prefixes
|
|
16
|
-
|
|
17
|
-
$ $0 --names "HTTP,WATCH" -c "bgBlue.bold,bgMagenta.bold" "http-server" "npm run watch"
|
|
18
|
-
|
|
19
|
-
- Send input to default
|
|
20
|
-
|
|
21
|
-
$ $0 --handle-input "nodemon" "npm run watch-js"
|
|
22
|
-
rs # Sends rs command to nodemon process
|
|
23
|
-
|
|
24
|
-
- Send input to specific child identified by index
|
|
25
|
-
|
|
26
|
-
$ $0 --handle-input "npm run watch-js" nodemon
|
|
27
|
-
1:rs
|
|
28
|
-
|
|
29
|
-
- Send input to specific child identified by name
|
|
30
|
-
|
|
31
|
-
$ $0 --handle-input -n js,srv "npm run watch-js" nodemon
|
|
32
|
-
srv:rs
|
|
33
|
-
|
|
34
|
-
- Shortened NPM run commands
|
|
35
|
-
|
|
36
|
-
$ $0 npm:watch-node npm:watch-js npm:watch-css
|
|
37
|
-
|
|
38
|
-
- Shortened NPM run command with wildcard
|
|
39
|
-
|
|
40
|
-
$ $0 npm:watch-*
|
|
41
|
-
|
|
42
|
-
For more details, visit https://github.com/open-cli-tools/concurrently
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const ExpandNpmShortcut = require('./expand-npm-shortcut');
|
|
2
|
-
const parser = new ExpandNpmShortcut();
|
|
3
|
-
|
|
4
|
-
it('returns same command if no npm: prefix is present', () => {
|
|
5
|
-
const commandInfo = {
|
|
6
|
-
name: 'echo',
|
|
7
|
-
command: 'echo foo'
|
|
8
|
-
};
|
|
9
|
-
expect(parser.parse(commandInfo)).toBe(commandInfo);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
for (const npmCmd of ['npm', 'yarn', 'pnpm']) {
|
|
13
|
-
describe(`with ${npmCmd}: prefix`, () => {
|
|
14
|
-
it(`expands to "${npmCmd} run <script> <args>"`, () => {
|
|
15
|
-
const commandInfo = {
|
|
16
|
-
name: 'echo',
|
|
17
|
-
command: `${npmCmd}:foo -- bar`
|
|
18
|
-
};
|
|
19
|
-
expect(parser.parse(commandInfo)).toEqual({
|
|
20
|
-
name: 'echo',
|
|
21
|
-
command: `${npmCmd} run foo -- bar`
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('sets name to script name if none', () => {
|
|
26
|
-
const commandInfo = {
|
|
27
|
-
command: `${npmCmd}:foo -- bar`
|
|
28
|
-
};
|
|
29
|
-
expect(parser.parse(commandInfo)).toEqual({
|
|
30
|
-
name: 'foo',
|
|
31
|
-
command: `${npmCmd} run foo -- bar`
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
|
|
4
|
-
module.exports = class ExpandNpmWildcard {
|
|
5
|
-
static readPackage() {
|
|
6
|
-
try {
|
|
7
|
-
const json = fs.readFileSync('package.json', { encoding: 'utf-8' });
|
|
8
|
-
return JSON.parse(json);
|
|
9
|
-
} catch (e) {
|
|
10
|
-
return {};
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
constructor(readPackage = ExpandNpmWildcard.readPackage) {
|
|
15
|
-
this.readPackage = readPackage;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
parse(commandInfo) {
|
|
19
|
-
const [, npmCmd, cmdName, args] = commandInfo.command.match(/(npm|yarn|pnpm) run (\S+)([^&]*)/) || [];
|
|
20
|
-
const wildcardPosition = (cmdName || '').indexOf('*');
|
|
21
|
-
|
|
22
|
-
// If the regex didn't match an npm script, or it has no wildcard,
|
|
23
|
-
// then we have nothing to do here
|
|
24
|
-
if (!cmdName || wildcardPosition === -1) {
|
|
25
|
-
return commandInfo;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!this.scripts) {
|
|
29
|
-
this.scripts = Object.keys(this.readPackage().scripts || {});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const preWildcard = _.escapeRegExp(cmdName.substr(0, wildcardPosition));
|
|
33
|
-
const postWildcard = _.escapeRegExp(cmdName.substr(wildcardPosition + 1));
|
|
34
|
-
const wildcardRegex = new RegExp(`^${preWildcard}(.*?)${postWildcard}$`);
|
|
35
|
-
|
|
36
|
-
return this.scripts
|
|
37
|
-
.filter(script => wildcardRegex.test(script))
|
|
38
|
-
.map(script => Object.assign({}, commandInfo, {
|
|
39
|
-
command: `${npmCmd} run ${script}${args}`,
|
|
40
|
-
name: script
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
};
|