add example regex match for stdout/err string

This commit is contained in:
Nick Fyson
2020-08-24 20:49:58 +01:00
parent 45e00a8e6a
commit cd22abcda8
7 changed files with 231 additions and 161 deletions

View File

@@ -30,18 +30,32 @@ export async function exec_wrapper(commandLine: string, args?: string[], options
}
};
const returnCode = await exec.exec(
commandLine,
args,
{
listeners: listeners,
...options
});
let returnCode: number;
try {
returnCode = await exec.exec(
commandLine,
args,
{
listeners: listeners,
...options
});
} catch (e) {
returnCode = 1;
}
if (returnCode === 0) {
throw new Error('The exit code was ' + returnCode + '?!');
}
if (stderr === stdout ) {
console.log('foo bar');
const regex = new RegExp("(No source code was seen during the build\\.|No JavaScript or TypeScript code found\\.)");
if (regex.test(stderr) || regex.test(stdout) ) {
throw new Error(`No source code was found. This can occur if the specified build commands failed to compile or process any code.
- Confirm that there is some source code for the specified language in the project.
- For codebases written in Go, JavaScript, TypeScript, and Python, do not specify
an explicit --command.
- For other languages, the --command must specify a "clean" build which compiles
https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning`);
}
return returnCode;
}