Use an options object for runJsonCodeQlCliCommand

This commit is contained in:
Koen Vlaswinkel
2023-02-20 16:37:48 +01:00
parent c6481ca6ff
commit 8afdabdd53

View File

@@ -564,9 +564,15 @@ export class CodeQLCliServer implements Disposable {
command: string[], command: string[],
commandArgs: string[], commandArgs: string[],
description: string, description: string,
{
addFormat = true, addFormat = true,
progressReporter?: ProgressReporter, progressReporter,
onLine?: OnLineCallback, onLine,
}: {
addFormat?: boolean;
progressReporter?: ProgressReporter;
onLine?: OnLineCallback;
} = {},
): Promise<OutputType> { ): Promise<OutputType> {
let args: string[] = []; let args: string[] = [];
if (addFormat) if (addFormat)
@@ -617,8 +623,13 @@ export class CodeQLCliServer implements Disposable {
command: string[], command: string[],
commandArgs: string[], commandArgs: string[],
description: string, description: string,
addFormat = true, {
progressReporter?: ProgressReporter, addFormat,
progressReporter,
}: {
addFormat?: boolean;
progressReporter?: ProgressReporter;
} = {},
): Promise<OutputType> { ): Promise<OutputType> {
const accessToken = await this.app.credentials.getExistingAccessToken(); const accessToken = await this.app.credentials.getExistingAccessToken();
@@ -628,9 +639,10 @@ export class CodeQLCliServer implements Disposable {
command, command,
[...extraArgs, ...commandArgs], [...extraArgs, ...commandArgs],
description, description,
{
addFormat, addFormat,
progressReporter, progressReporter,
async (line) => { onLine: async (line) => {
if (line.startsWith("Enter value for --github-auth-stdin")) { if (line.startsWith("Enter value for --github-auth-stdin")) {
try { try {
return await this.app.credentials.getAccessToken(); return await this.app.credentials.getAccessToken();
@@ -647,6 +659,7 @@ export class CodeQLCliServer implements Disposable {
return undefined; return undefined;
}, },
},
); );
} }
@@ -714,7 +727,9 @@ export class CodeQLCliServer implements Disposable {
["resolve", "qlref"], ["resolve", "qlref"],
subcommandArgs, subcommandArgs,
"Resolving qlref", "Resolving qlref",
false, {
addFormat: false,
},
); );
} }
@@ -787,7 +802,9 @@ export class CodeQLCliServer implements Disposable {
["resolve", "ml-models"], ["resolve", "ml-models"],
args, args,
"Resolving ML models", "Resolving ML models",
false, {
addFormat: false,
},
); );
} }
@@ -811,8 +828,9 @@ export class CodeQLCliServer implements Disposable {
["resolve", "ram"], ["resolve", "ram"],
args, args,
"Resolving RAM settings", "Resolving RAM settings",
true, {
progressReporter, progressReporter,
},
); );
} }
/** /**
@@ -1227,12 +1245,13 @@ export class CodeQLCliServer implements Disposable {
async packAdd(dir: string, queryLanguage: QueryLanguage) { async packAdd(dir: string, queryLanguage: QueryLanguage) {
const args = ["--dir", dir]; const args = ["--dir", dir];
args.push(`codeql/${queryLanguage}-all`); args.push(`codeql/${queryLanguage}-all`);
const addFormat = false;
return this.runJsonCodeQlCliCommandWithAuthentication( return this.runJsonCodeQlCliCommandWithAuthentication(
["pack", "add"], ["pack", "add"],
args, args,
`Adding and installing ${queryLanguage} pack dependency.`, `Adding and installing ${queryLanguage} pack dependency.`,
addFormat, {
addFormat: false,
},
); );
} }