Skip to content

Commit 29fc648

Browse files
committed
Make "Create Query" command work with vscode-codeql-starter
We set up the "Create Query" command with the assumption that the first folder in the workspace is the parent folder. This is true for the `codespaces-codeql` repo where we expect to use this command. However, for the `vscode-codeql-starter` repo, the top level folders are QL packs: - codeql-custom-queries-cpp - codeql-custom-queries-ruby ... etc. In order to make the command work for people using the starter repo, we'll need to introduce a check for these QL packs when we decide the storage path. The end goal is to replace the starter workspace completely with the codespaces-codeql repo, so this code can be removed in the future when we retire the repo. Until then, the command will need this to be able to work in both starter workspaces.
1 parent 191c0d1 commit 29fc648

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

extensions/ql-vscode/src/skeleton-query.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,15 @@ export class SkeletonQueryWizard {
9191

9292
const firstFolder = workspaceFolders[0];
9393

94-
return firstFolder.uri.path;
94+
// For the vscode-codeql-starter repo, the first folder will be a ql pack
95+
// so we need to get the parent folder
96+
if (firstFolder.uri.path.includes("codeql-custom-queries")) {
97+
// slice off the last part of the path and return the parent folder
98+
return firstFolder.uri.path.split("/").slice(0, -1).join("/");
99+
} else {
100+
// if the first folder is not a ql pack, then we are in a normal workspace
101+
return firstFolder.uri.path;
102+
}
95103
}
96104

97105
private async chooseLanguage() {

0 commit comments

Comments
 (0)