make ErrorMatcher an object rather than a tuple

This commit is contained in:
Nick Fyson 2020-09-11 18:30:07 +01:00
parent 1fb7c81099
commit b3b99014eb
12 changed files with 58 additions and 48 deletions

View file

@ -1,17 +1,23 @@
export type ErrorMatcher = [number|null, RegExp|null, string];
// defines properties to match against the result of executed commands,
// and a custom error to return when a match is found
export interface ErrorMatcher {
exitCode?: number; // exit code of the run process
outputRegex?: RegExp; // pattern to match against either stdout or stderr
message: string; // the error message that will be thrown for a matching process
}
// exported only for testing purposes
export const namedMatchersForTesting: { [key: string]: ErrorMatcher } = {
/*
In due course it may be possible to remove the regex, if/when javascript also exits with code 32.
*/
noSourceCodeFound: [
32,
new RegExp("No JavaScript or TypeScript code found\\."),
"No code found during the build. Please see:\n" +
"https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning#no-code-found-during-the-build"
],
noSourceCodeFound: {
exitCode: 32,
outputRegex: new RegExp("No JavaScript or TypeScript code found\\."),
message: "No code found during the build. Please see:\n" +
"https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning#no-code-found-during-the-build"
},
};
// we collapse the matches into an array for use in execErrorCatcher