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