Skip to content

Commit ea8c11c

Browse files
committed
Update codeql.ts
1 parent df49e47 commit ea8c11c

File tree

1 file changed

+22
-36
lines changed

1 file changed

+22
-36
lines changed

src/codeql.ts

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,17 @@ export interface ResolveQueriesOutput {
6161
[queryPath: string]: {}
6262
};
6363
}
64-
64+
const options = {
65+
ignoreReturnCode: true,
66+
listeners: {
67+
stdout: (data: Buffer) => {
68+
core.debug("Debug" + data.toString());
69+
},
70+
stderr: (data: Buffer) => {
71+
core.error("Error occured" + data.toString());
72+
}
73+
}
74+
};
6575
/**
6676
* Environment variable used to store the location of the CodeQL CLI executable.
6777
* Value is set by setupCodeQL and read by getCodeQL.
@@ -185,10 +195,14 @@ function getCodeQLForCmd(cmd: string): CodeQL {
185195
'--language=' + language
186196
],
187197
{
188-
silent: true,
198+
ignoreReturnCode: true,
189199
listeners: {
190-
stdout: (data) => { extractorPath += data.toString(); },
191-
stderr: (data) => { process.stderr.write(data); }
200+
stdout: (data: Buffer) => {
201+
core.debug("Debug" + data.toString());
202+
},
203+
stderr: (data: Buffer) => {
204+
core.error("Error occured" + data.toString());
205+
}
192206
}
193207
});
194208

@@ -203,26 +217,15 @@ function getCodeQLForCmd(cmd: string): CodeQL {
203217
databasePath,
204218
'--',
205219
traceCommand
206-
]);
220+
], options);
207221
},
208222
finalizeDatabase: async function(databasePath: string) {
209223
core.debug("Finalizing " + databasePath);
210224
await exec.exec(cmd, [
211225
'database',
212226
'finalize',
213227
databasePath
214-
],
215-
{
216-
ignoreReturnCode: true,
217-
listeners: {
218-
stdout: (data: Buffer) => {
219-
core.debug("Debug" + data.toString());
220-
},
221-
stderr: (data: Buffer) => {
222-
core.error("Error occured" + data.toString());
223-
}
224-
}
225-
});
228+
], options );
226229
},
227230
resolveQueries: async function(queries: string[]) {
228231
let output = '';
@@ -233,14 +236,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
233236
'queries',
234237
...queries,
235238
'--format=bylanguage'
236-
],
237-
{
238-
listeners: {
239-
stdout: (data: Buffer) => {
240-
output += data.toString();
241-
}
242-
}
243-
});
239+
], options);
244240

245241
return JSON.parse(output);
246242
},
@@ -255,17 +251,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
255251
'--output=' + sarifFile,
256252
'--no-sarif-add-snippets',
257253
querySuite
258-
],
259-
{
260-
listeners: {
261-
stdout: (data: Buffer) => {
262-
core.debug("Debug" + data.toString());
263-
},
264-
stderr: (data: Buffer) => {
265-
core.error("Error occured" + data.toString());
266-
}
267-
}
268-
});
254+
], options);
269255
}
270256
};
271257
}

0 commit comments

Comments
 (0)