Skip to content

Commit 6010f85

Browse files
committed
Reimplement resolveExtractor() as wrapper over resolveLanguages()
By wrapping `resolveLanguages()`, which is memoized, we can avoid executing `codeql resolve extractor` several times over the course of an analysis.
1 parent 311292c commit 6010f85

1 file changed

Lines changed: 5 additions & 26 deletions

File tree

src/codeql.ts

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -946,32 +946,11 @@ async function getCodeQLForCmd(
946946
await new toolrunner.ToolRunner(cmd, args).exec();
947947
},
948948
async resolveExtractor(language: Language): Promise<string> {
949-
// Request it using `format=json` so we don't need to strip the trailing new line generated by
950-
// the CLI.
951-
let extractorPath = "";
952-
await new toolrunner.ToolRunner(
953-
cmd,
954-
[
955-
"resolve",
956-
"extractor",
957-
"--format=json",
958-
`--language=${language}`,
959-
"--extractor-include-aliases",
960-
...getExtraOptionsFromEnv(["resolve", "extractor"]),
961-
],
962-
{
963-
silent: true,
964-
listeners: {
965-
stdout: (data) => {
966-
extractorPath += data.toString();
967-
},
968-
stderr: (data) => {
969-
process.stderr.write(data);
970-
},
971-
},
972-
},
973-
).exec();
974-
return JSON.parse(extractorPath) as string;
949+
// A previous implementation executed `codeql resolve extractor`.
950+
// This can be a bit slow due to the JVM startup cost. Instead, get
951+
// the extractor path from resolveLanguages(), which caches its output.
952+
const extractors = await this.resolveLanguages();
953+
return extractors[language][0];
975954
},
976955
async resolveQueriesStartingPacks(queries: string[]): Promise<string[]> {
977956
const codeqlArgs = [

0 commit comments

Comments
 (0)