From 4bfb91a5ebd54af5a0b3e21fc81d9b022d4b2c9c Mon Sep 17 00:00:00 2001 From: Pascal Jufer Date: Fri, 20 May 2022 09:48:45 +0200 Subject: [PATCH 1/2] Fix `command-` syntax capturing for `--success` --- src/completion-listener.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/completion-listener.ts b/src/completion-listener.ts index 60a10faf..cc59ad90 100644 --- a/src/completion-listener.ts +++ b/src/completion-listener.ts @@ -43,7 +43,10 @@ export class CompletionListener { return events[0].exitCode === 0; } else if (this.successCondition === 'last') { return events[events.length - 1].exitCode === 0; - } else if (!/^!?command-.+$/.test(this.successCondition)) { + } + + const commandSyntaxMatch = this.successCondition.match(/^!?command-(.+)$/); + if (commandSyntaxMatch === null) { // If not a `command-` syntax, then it's an 'all' condition or it's treated as such. return events.every(({ exitCode }) => exitCode === 0); } @@ -51,7 +54,7 @@ export class CompletionListener { // Check `command-` syntax condition. // Note that a command's `name` is not necessarily unique, // in which case all of them must meet the success condition. - const [, nameOrIndex] = this.successCondition.split('-'); + const nameOrIndex = commandSyntaxMatch[1]; const targetCommandsEvents = events.filter(({ command, index }) => ( command.name === nameOrIndex || index === Number(nameOrIndex) From 6a9b0359bb10131e8fb6448cd0e0f6d272bbeef3 Mon Sep 17 00:00:00 2001 From: Pascal Jufer Date: Sun, 22 May 2022 09:08:29 +0200 Subject: [PATCH 2/2] Relaxing condition for non-match of command-syntax Co-authored-by: Gustavo Henke --- src/completion-listener.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/completion-listener.ts b/src/completion-listener.ts index cc59ad90..18c98cc9 100644 --- a/src/completion-listener.ts +++ b/src/completion-listener.ts @@ -46,7 +46,7 @@ export class CompletionListener { } const commandSyntaxMatch = this.successCondition.match(/^!?command-(.+)$/); - if (commandSyntaxMatch === null) { + if (commandSyntaxMatch == null) { // If not a `command-` syntax, then it's an 'all' condition or it's treated as such. return events.every(({ exitCode }) => exitCode === 0); }