Skip to content

Commit ecbc325

Browse files
paescujgustavohenke
andauthoredMay 22, 2022
Fix command- syntax capturing for --success (#325)
Co-authored-by: Gustavo Henke <guhenke@gmail.com>
1 parent 6f1e11d commit ecbc325

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎src/completion-listener.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,18 @@ export class CompletionListener {
4343
return events[0].exitCode === 0;
4444
} else if (this.successCondition === 'last') {
4545
return events[events.length - 1].exitCode === 0;
46-
} else if (!/^!?command-.+$/.test(this.successCondition)) {
46+
}
47+
48+
const commandSyntaxMatch = this.successCondition.match(/^!?command-(.+)$/);
49+
if (commandSyntaxMatch == null) {
4750
// If not a `command-` syntax, then it's an 'all' condition or it's treated as such.
4851
return events.every(({ exitCode }) => exitCode === 0);
4952
}
5053

5154
// Check `command-` syntax condition.
5255
// Note that a command's `name` is not necessarily unique,
5356
// in which case all of them must meet the success condition.
54-
const [, nameOrIndex] = this.successCondition.split('-');
57+
const nameOrIndex = commandSyntaxMatch[1];
5558
const targetCommandsEvents = events.filter(({ command, index }) => (
5659
command.name === nameOrIndex
5760
|| index === Number(nameOrIndex)

0 commit comments

Comments
 (0)
Please sign in to comment.