Skip to content

Commit 086df15

Browse files
committed
Use file system path
On windows, the `Uri.path` will return an extra folder, as we can see in the tests: ``` ENOENT: no such file or directory, open 'D:\C:\Users\RUNNER~1\AppData\Local\Temp\tmp-4784XPDQPb5jM6IW\test-ql-pack-ruby\qlpack.yml' ``` Let's use `Uri.fsPath` instead.
1 parent 3e87a2d commit 086df15

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

extensions/ql-vscode/src/qlpack-generator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class QlPackGenerator {
6464
}
6565

6666
private async createQlPackYaml() {
67-
const qlPackFilePath = join(this.folderUri.path, this.qlpackFileName);
67+
const qlPackFilePath = join(this.folderUri.fsPath, this.qlpackFileName);
6868

6969
const qlPackYml = {
7070
name: this.qlpackName,
@@ -78,7 +78,7 @@ export class QlPackGenerator {
7878
}
7979

8080
private async createExampleQlFile() {
81-
const exampleQlFilePath = join(this.folderUri.path, "example.ql");
81+
const exampleQlFilePath = join(this.folderUri.fsPath, "example.ql");
8282

8383
const exampleQl = `
8484
/**
@@ -98,6 +98,6 @@ select "Hello, world!"
9898
}
9999

100100
private async createCodeqlPackLockYaml() {
101-
await this.cliServer.packAdd(this.folderUri.path, this.queryLanguage);
101+
await this.cliServer.packAdd(this.folderUri.fsPath, this.queryLanguage);
102102
}
103103
}

extensions/ql-vscode/test/vscode-tests/minimal-workspace/qlpack-generator.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { join } from "path";
22
import { existsSync } from "fs";
33
import { QlPackGenerator, QueryLanguage } from "../../../src/qlpack-generator";
44
import { CodeQLCliServer } from "../../../src/cli";
5-
import { isFolderAlreadyInWorkspace } from "../../../src/helpers";
6-
import { workspace } from "vscode";
5+
import { Uri, workspace } from "vscode";
76
import { getErrorMessage } from "../../../src/pure/helpers-pure";
87
import * as tmp from "tmp";
98

@@ -22,7 +21,7 @@ describe("QlPackGenerator", () => {
2221

2322
language = "ruby";
2423
packFolderName = `test-ql-pack-${language}`;
25-
packFolderPath = join(dir.name, packFolderName);
24+
packFolderPath = Uri.file(join(dir.name, packFolderName)).fsPath;
2625

2726
qlPackYamlFilePath = join(packFolderPath, "qlpack.yml");
2827
exampleQlFilePath = join(packFolderPath, "example.ql");
@@ -60,15 +59,16 @@ describe("QlPackGenerator", () => {
6059
});
6160

6261
it("should generate a QL pack", async () => {
63-
expect(isFolderAlreadyInWorkspace(packFolderName)).toBe(false);
62+
expect(existsSync(packFolderPath)).toBe(false);
6463
expect(existsSync(qlPackYamlFilePath)).toBe(false);
6564
expect(existsSync(exampleQlFilePath)).toBe(false);
6665

6766
await generator.generate();
6867

69-
expect(isFolderAlreadyInWorkspace(packFolderName)).toBe(true);
68+
expect(existsSync(packFolderPath)).toBe(true);
7069
expect(existsSync(qlPackYamlFilePath)).toBe(true);
7170
expect(existsSync(exampleQlFilePath)).toBe(true);
71+
7272
expect(packAddSpy).toHaveBeenCalledWith(packFolderPath, language);
7373
});
7474
});

0 commit comments

Comments
 (0)