ensure matchers not applied if exit code is zero
This commit is contained in:
parent
231537b08e
commit
6a43a6178d
3 changed files with 6 additions and 4 deletions
2
lib/exec_wrapper.js
generated
2
lib/exec_wrapper.js
generated
|
|
@ -60,7 +60,7 @@ async function exec_wrapper(commandLine, args, matchers, options) {
|
|||
catch (e) {
|
||||
originalReturnValue = e;
|
||||
}
|
||||
if (matchers) {
|
||||
if (matchers && originalReturnValue !== 0) {
|
||||
for (const [customCode, regex, message] of matchers) {
|
||||
if (customCode === originalReturnValue || regex.test(stderr) || regex.test(stdout)) {
|
||||
throw new Error(message);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"exec_wrapper.js","sourceRoot":"","sources":["../src/exec_wrapper.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAItC;;;;;;;;;;GAUG;AACI,KAAK,UAAU,YAAY,CAAC,WAAmB,EAAE,IAAe,EACpC,QAAqC,EACrC,OAAwB;;IAEzD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,4GAA4G;IAC5G,MAAM,gBAAgB,SAAG,OAAO,0CAAE,SAAS,CAAC;IAC5C,IAAI,SAAS,GAAG;QACd,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,OAAA,gBAAgB,0CAAE,MAAM,MAAK,SAAS,EAAE;gBAC1C,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAC/B;iBAAM;gBACL,iFAAiF;gBACjF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAC5B;QAEH,CAAC;QACD,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,OAAA,gBAAgB,0CAAE,MAAM,MAAK,SAAS,EAAE;gBAC1C,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EAAE;QAC3C,OAAO,mBAAmB,CAAC;KAC5B;SAAM;QACL,MAAM,mBAAmB,CAAC;KAC3B;AACH,CAAC;AA1DD,oCA0DC"}
|
||||
|
|
@ -2,6 +2,8 @@ import * as exec from '@actions/exec';
|
|||
import * as im from '@actions/exec/lib/interfaces';
|
||||
|
||||
|
||||
export type ErrorMatcher = [number, RegExp, string];
|
||||
|
||||
/**
|
||||
* Wrapper for exec.exec which checks for specific return code and/or regex matches in console output.
|
||||
* Output will be streamed to the live console as well as captured for subsequent processing.
|
||||
|
|
@ -14,7 +16,7 @@ import * as im from '@actions/exec/lib/interfaces';
|
|||
* @returns Promise<number> exit code
|
||||
*/
|
||||
export async function exec_wrapper(commandLine: string, args?: string[],
|
||||
matchers?: [[number, RegExp, string]],
|
||||
matchers?: ErrorMatcher[],
|
||||
options?: im.ExecOptions): Promise<number> {
|
||||
|
||||
let stdout = '';
|
||||
|
|
@ -58,7 +60,7 @@ export async function exec_wrapper(commandLine: string, args?: string[],
|
|||
originalReturnValue = e;
|
||||
}
|
||||
|
||||
if (matchers) {
|
||||
if (matchers && originalReturnValue !== 0) {
|
||||
for (const [customCode, regex, message] of matchers) {
|
||||
if (customCode === originalReturnValue || regex.test(stderr) || regex.test(stdout) ) {
|
||||
throw new Error(message);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue