Skip to content

Commit c1c096d

Browse files
committed
added success conditon all but first
1 parent 10ff00c commit c1c096d

4 files changed

Lines changed: 44 additions & 7 deletions

File tree

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ General
125125
"|" [default: ","]
126126
-r, --raw Output only raw output of processes, disables prettifying
127127
and concurrently coloring. [boolean]
128-
-s, --success Return exit code of zero or one based on the success or
129-
failure of the "first" child to terminate, the "last
130-
child", or succeed only if "all" child processes succeed.
131-
[choices: "first", "last", "all"] [default: "all"]
128+
-s, --success Return exit code of zero or one based on the success or failure
129+
of the "first" child to terminate, the "last child", "all-but-
130+
first" child success, or succeeed only if "all" child processes
131+
succeed
132+
[choices: "first", "last", "all-but-first", "all"]
133+
[default: "all"]
132134
--no-color Disables colors from logging [boolean]
133135
134136
Prefix styling

bin/concurrently.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ const args = yargs
3737
alias: 'success',
3838
describe:
3939
'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'],
40+
'of the "first" child to terminate, the "last child", all but ' +
41+
'the first child success, or succeeed only if "all" child ' +
42+
'processes succeed.',
43+
choices: ['first', 'last', 'all-but-first', 'all'],
4344
default: defaults.success
4445
},
4546
'r': {

src/completion-listener.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ module.exports = class CompletionListener {
1616
case 'last':
1717
return exitCodes[exitCodes.length - 1] === 0;
1818

19+
case 'all-but-first':
20+
const [, ...allButFirst] = exitCodes;
21+
return allButFirst.every(code => code === 0);
22+
1923
default:
2024
return exitCodes.every(exitCode => exitCode === 0);
2125
/* eslint-enable indent */

src/completion-listener.spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,33 @@ describe('with success condition set to last', () => {
8686
return expect(result).rejects.toEqual([{ exitCode: 0 }, { exitCode: 1 }]);
8787
});
8888
});
89+
90+
describe('with success condition set to all-but-first', () => {
91+
beforeEach(() => {
92+
commands.push(createFakeCommand('oof'));
93+
});
94+
95+
it('succeeds if all but first process to exit has code 0', () => {
96+
const result = createController('all-but-first').listen(commands);
97+
98+
commands[0].close.next({ exitCode: 1 });
99+
commands[1].close.next({ exitCode: 0 });
100+
commands[2].close.next({ exitCode: 0 });
101+
102+
scheduler.flush();
103+
104+
return expect(result).resolves.toEqual([{ exitCode: 1 }, { exitCode: 0 }, { exitCode: 0 }]);
105+
});
106+
107+
it('fails if last process to exit has non-0 code', () => {
108+
const result = createController('first').listen(commands);
109+
110+
commands[0].close.next({ exitCode: 1 });
111+
commands[1].close.next({ exitCode: 0 });
112+
commands[2].close.next({ exitCode: 1 });
113+
114+
scheduler.flush();
115+
116+
return expect(result).rejects.toEqual([{ exitCode: 1 }, { exitCode: 0 }, { exitCode: 1 }]);
117+
});
118+
});

0 commit comments

Comments
 (0)