Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit 1955215

Browse files
xcorailSam Lanning
andauthored
Apply suggestions from code review
Co-Authored-By: Sam Lanning <[email protected]>
1 parent ef1c508 commit 1955215

File tree

1 file changed

+3
-4
lines changed
  • codeql-learninglab-check/package/src

1 file changed

+3
-4
lines changed

codeql-learninglab-check/package/src/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const writeFile = promisify(fs.writeFile);
2222
* If specific queries should be run, RUN_ALL cannot be true
2323
*/
2424
const RUN_ALL = process.env.RUN_ALL === 'true';
25-
const QUERY_PATTERN: RegExp = RegExp(String(process.env.QUERY_PATTERN));
25+
const QUERY_PATTERN: RegExp | null = process.env.QUERY_PATTERN !== '' ? RegExp(process.env.QUERY_PATTERN) : null;
2626

2727
/**
2828
* Set to true to avoid using the GitHub API to post a comment
@@ -124,9 +124,8 @@ function isConfig(config: any): config is Config {
124124
*/
125125
const queriesChanged = new Set<string>();
126126
let unableToGetChangedQueries = false;
127-
let queryPattern = (process.env.QUERY_PATTERN!="");
128127

129-
if (!RUN_ALL && !queryPattern) {
128+
if (!RUN_ALL && !QUERY_PATTERN) {
130129

131130
/*
132131
* There are a few different ways in which we may determine which queries
@@ -277,7 +276,7 @@ function isConfig(config: any): config is Config {
277276
for (const query of Object.keys(config.expectedResults)) {
278277
const exists = await access(query, fs.constants.R_OK).then(() => true, () => false);
279278
// Run the query if either it's changed, or runAll is true
280-
if (exists && (RUN_ALL || unableToGetChangedQueries || queriesChanged.has(query)) || (queryPattern && QUERY_PATTERN.test(query))) {
279+
if (exists && (RUN_ALL || unableToGetChangedQueries || queriesChanged.has(query)) || (QUERY_PATTERN && QUERY_PATTERN.test(query))) {
281280
queriesToRun.push(query);
282281
}
283282
}

0 commit comments

Comments
 (0)