mirror of
https://github.com/github/codeql-action.git
synced 2025-12-28 02:00:12 +08:00
add example regex match for stdout/err string
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user