Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ export class DatabaseManager extends DisposableObject {
const firstWorkspaceFolder = getFirstWorkspaceFolder();
const folderName = `codeql-custom-queries-${databaseItem.language}`;

const qlpackStoragePath = join(firstWorkspaceFolder, folderName);

if (
existsSync(join(firstWorkspaceFolder, folderName)) ||
existsSync(qlpackStoragePath) ||
isFolderAlreadyInWorkspace(folderName)
) {
return;
Expand All @@ -276,7 +278,8 @@ export class DatabaseManager extends DisposableObject {
const qlPackGenerator = new QlPackGenerator(
databaseItem.language,
this.cli,
join(firstWorkspaceFolder, folderName),
qlpackStoragePath,
qlpackStoragePath,
);
await qlPackGenerator.generate();
} catch (e: unknown) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class QlPackGenerator {
private readonly queryLanguage: QueryLanguage,
private readonly cliServer: CodeQLCliServer,
private readonly storagePath: string,
private readonly queryStoragePath: string,
private readonly includeFolderNameInQlpackName: boolean = false,
) {
this.qlpackVersion = "1.0.0";
Expand Down Expand Up @@ -91,7 +92,7 @@ export class QlPackGenerator {
}

public async createExampleQlFile(fileName = "example.ql") {
const exampleQlFilePath = join(this.folderUri.fsPath, fileName);
const exampleQlFilePath = join(this.queryStoragePath, fileName);

const exampleQl = `
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,10 @@ export class SkeletonQueryWizard {

private createQlPackGenerator() {
if (this.qlPackStoragePath === undefined) {
throw new Error("Query pack storage path is undefined");
throw new Error("QL pack storage path is undefined");
}
if (this.queryStoragePath === undefined) {
throw new Error("Query storage path is undefined");
}
if (this.language === undefined) {
throw new Error("Language is undefined");
Expand All @@ -472,6 +475,7 @@ export class SkeletonQueryWizard {
this.language,
this.cliServer,
this.qlPackStoragePath,
this.queryStoragePath,
includeFolderNameInQlpackName,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe("QlPackGenerator", () => {
language as QueryLanguage,
mockCli,
packFolderPath,
packFolderPath,
);
});

Expand Down Expand Up @@ -128,6 +129,7 @@ describe("QlPackGenerator", () => {
language as QueryLanguage,
mockCli,
packFolderPath,
packFolderPath,
true,
);
});
Expand Down Expand Up @@ -161,6 +163,7 @@ describe("QlPackGenerator", () => {
language as QueryLanguage,
mockCli,
packFolderPath,
packFolderPath,
true,
);
});
Expand Down Expand Up @@ -195,6 +198,7 @@ describe("QlPackGenerator", () => {
language as QueryLanguage,
mockCli,
packFolderPath,
packFolderPath,
true,
);
});
Expand Down