Skip to content

Commit e34c66b

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 d3127b7 commit e34c66b

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
@@ -974,32 +974,11 @@ async function getCodeQLForCmd(
974974
await new toolrunner.ToolRunner(cmd, args).exec();
975975
},
976976
async resolveExtractor(language: Language): Promise<string> {
977-
// Request it using `format=json` so we don't need to strip the trailing new line generated by
978-
// the CLI.
979-
let extractorPath = "";
980-
await new toolrunner.ToolRunner(
981-
cmd,
982-
[
983-
"resolve",
984-
"extractor",
985-
"--format=json",
986-
`--language=${language}`,
987-
"--extractor-include-aliases",
988-
...getExtraOptionsFromEnv(["resolve", "extractor"]),
989-
],
990-
{
991-
silent: true,
992-
listeners: {
993-
stdout: (data) => {
994-
extractorPath += data.toString();
995-
},
996-
stderr: (data) => {
997-
process.stderr.write(data);
998-
},
999-
},
1000-
},
1001-
).exec();
1002-
return JSON.parse(extractorPath) as string;
977+
// A previous implementation executed `codeql resolve extractor`.
978+
// This can be a bit slow due to the JVM startup cost. Instead, get
979+
// the extractor path from resolveLanguages(), which caches its output.
980+
const extractors = await this.resolveLanguages();
981+
return extractors[language][0];
1003982
},
1004983
async resolveQueriesStartingPacks(queries: string[]): Promise<string[]> {
1005984
const codeqlArgs = [

0 commit comments

Comments
 (0)