move error matcher definition into dedicated file
This commit is contained in:
Родитель
1f3ce75844
Коммит
7dbaff09b6
|
@ -22,6 +22,7 @@ const globalutil = __importStar(require("util"));
|
|||
const v4_1 = __importDefault(require("uuid/v4"));
|
||||
const api = __importStar(require("./api-client"));
|
||||
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
||||
const error_matcher_1 = require("./error_matcher");
|
||||
const exec_wrapper_1 = require("./exec_wrapper");
|
||||
const util = __importStar(require("./util"));
|
||||
/**
|
||||
|
@ -296,7 +297,7 @@ function getCodeQLForCmd(cmd) {
|
|||
databasePath,
|
||||
'--',
|
||||
traceCommand
|
||||
], [[0, new RegExp("(No source code was seen during the build\\.|No JavaScript or TypeScript code found\\.)"), 'foo bar']]);
|
||||
], error_matcher_1.error_matchers);
|
||||
},
|
||||
finalizeDatabase: async function (databasePath) {
|
||||
await exec_wrapper_1.exec_wrapper(cmd, [
|
||||
|
@ -304,7 +305,7 @@ function getCodeQLForCmd(cmd) {
|
|||
'finalize',
|
||||
...getExtraOptionsFromEnv(['database', 'finalize']),
|
||||
databasePath
|
||||
], [[0, new RegExp("(No source code was seen during the build\\.|No JavaScript or TypeScript code found\\.)"), 'foo bar']]);
|
||||
], error_matcher_1.error_matchers);
|
||||
},
|
||||
resolveQueries: async function (queries, extraSearchPath) {
|
||||
const codeqlArgs = [
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -0,0 +1,6 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.error_matchers = [
|
||||
[32, new RegExp("No JavaScript or TypeScript code found\\."), 'foo bar']
|
||||
];
|
||||
//# sourceMappingURL=error_matcher.js.map
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"error_matcher.js","sourceRoot":"","sources":["../src/error_matcher.ts"],"names":[],"mappings":";;AAGa,QAAA,cAAc,GAAmB;IAC5C,CAAC,EAAE,EAAE,IAAI,MAAM,CAAC,2CAA2C,CAAC,EAAE,SAAS,CAAC;CACzE,CAAC"}
|
|
@ -64,7 +64,7 @@ async function exec_wrapper(commandLine, args, matchers, options) {
|
|||
return returnState;
|
||||
if (matchers) {
|
||||
for (const [customCode, regex, message] of matchers) {
|
||||
if (customCode === returnState || regex.test(stderr) || regex.test(stdout)) {
|
||||
if (customCode === returnState || regex && (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;AAMtC;;;;;;;;;;GAUG;AACI,KAAK,UAAU,YAAY,CAAC,WAAmB,EAAE,IAAe,EACpC,QAAyB,EACzB,OAAwB;;IAEzD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,IAAI,SAAS,GAAG;QACd,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,aAAA,OAAO,0CAAE,SAAS,0CAAE,MAAM,MAAK,SAAS,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACL,2FAA2F;gBAC3F,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,aAAA,OAAO,0CAAE,SAAS,0CAAE,MAAM,MAAK,SAAS,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACL,2FAA2F;gBAC3F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC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,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAG;gBACtF,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;aAC1B;SACF;KACF;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnC,qFAAqF;QACrF,UAAI,OAAO,0CAAE,gBAAgB,EAAE;YAC7B,OAAO,WAAW,CAAC;SACpB;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,iBAAiB,WAAW,4BAA4B,WAAW,EAAE,CAAC,CAAC;SACxF;KACF;SAAM;QACL,MAAM,WAAW,CAAC;KACnB;AACH,CAAC;AAjED,oCAiEC"}
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -12,6 +12,7 @@ import uuidV4 from 'uuid/v4';
|
|||
|
||||
import * as api from './api-client';
|
||||
import * as defaults from './defaults.json'; // Referenced from codeql-action-sync-tool!
|
||||
import { errorMatchers} from './error_matcher';
|
||||
import { exec_wrapper } from './exec_wrapper';
|
||||
import { Language } from './languages';
|
||||
import * as util from './util';
|
||||
|
@ -390,7 +391,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
|
|||
'--',
|
||||
traceCommand
|
||||
],
|
||||
[[0, new RegExp("(No source code was seen during the build\\.|No JavaScript or TypeScript code found\\.)"), 'foo bar']]
|
||||
errorMatchers
|
||||
);
|
||||
},
|
||||
finalizeDatabase: async function(databasePath: string) {
|
||||
|
@ -401,7 +402,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
|
|||
...getExtraOptionsFromEnv(['database', 'finalize']),
|
||||
databasePath
|
||||
],
|
||||
[[0, new RegExp("(No source code was seen during the build\\.|No JavaScript or TypeScript code found\\.)"), 'foo bar']]);
|
||||
errorMatchers);
|
||||
},
|
||||
resolveQueries: async function(queries: string[], extraSearchPath: string | undefined) {
|
||||
const codeqlArgs = [
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
export type ErrorMatcher = [number|null, RegExp|null, string];
|
||||
|
||||
const namedMatchers: { [key: string]: ErrorMatcher } = {
|
||||
noSourceCodeFound: [
|
||||
32,
|
||||
null,
|
||||
`No source code was seen during the build. Please see...
|
||||
https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning#no-code-found-during-the-build`
|
||||
],
|
||||
noSourceCodeFoundJavascript: [
|
||||
null,
|
||||
new RegExp("No JavaScript or TypeScript code found\\."),
|
||||
`No source code was seen during the build. Please see...
|
||||
https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning#no-code-found-during-the-build`
|
||||
]
|
||||
};
|
||||
|
||||
export const errorMatchers = Object.values(namedMatchers);
|
|
@ -1,7 +1,8 @@
|
|||
import * as exec from '@actions/exec';
|
||||
import test from 'ava';
|
||||
|
||||
import { exec_wrapper, ErrorMatcher } from './exec_wrapper';
|
||||
import { ErrorMatcher } from './error_matcher';
|
||||
import { exec_wrapper } from './exec_wrapper';
|
||||
import {setupTests} from './testing-utils';
|
||||
// import fs from 'fs';
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import * as exec from '@actions/exec';
|
||||
import * as im from '@actions/exec/lib/interfaces';
|
||||
|
||||
|
||||
export type ErrorMatcher = [number, RegExp, string];
|
||||
import {ErrorMatcher} from './error_matcher';
|
||||
|
||||
/**
|
||||
* Wrapper for exec.exec which checks for specific return code and/or regex matches in console output.
|
||||
|
@ -64,7 +63,7 @@ export async function exec_wrapper(commandLine: string, args?: string[],
|
|||
|
||||
if (matchers) {
|
||||
for (const [customCode, regex, message] of matchers) {
|
||||
if (customCode === returnState || regex.test(stderr) || regex.test(stdout) ) {
|
||||
if (customCode === returnState || regex && (regex.test(stderr) || regex.test(stdout)) ) {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче