Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 428255d

Browse files
committed
fixed use wsl feature
convert path wsl after full path constructed leetCodeRootPathInWsl no longer used getLeetCodeRootPath function removed since it has only one reference after the bug fixed
1 parent 1c4a39e commit 428255d

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/leetCodeExecutor.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ import { toWslPath, useWsl } from "./utils/wslUtils";
1414

1515
class LeetCodeExecutor implements Disposable {
1616
private leetCodeRootPath: string;
17-
private leetCodeRootPathInWsl: string;
1817
private nodeExecutable: string;
1918
private configurationChangeListener: Disposable;
2019

2120
constructor() {
2221
this.leetCodeRootPath = path.join(__dirname, "..", "..", "node_modules", "vsc-leetcode-cli");
23-
this.leetCodeRootPathInWsl = "";
2422
this.nodeExecutable = this.getNodePath();
2523
this.configurationChangeListener = workspace.onDidChangeConfiguration((event: ConfigurationChangeEvent) => {
2624
if (event.affectsConfiguration("leetcode.nodePath")) {
@@ -29,18 +27,13 @@ class LeetCodeExecutor implements Disposable {
2927
}, this);
3028
}
3129

32-
public async getLeetCodeRootPath(): Promise<string> { // not wrapped by ""
33-
if (wsl.useWsl()) {
34-
if (!this.leetCodeRootPathInWsl) {
35-
this.leetCodeRootPathInWsl = `${await wsl.toWslPath(this.leetCodeRootPath)}`;
30+
getLeetCodeBinaryPath() {
31+
return __awaiter(this, void 0, void 0, function* () {
32+
if (wsl.useWsl()) {
33+
return `${yield wsl.toWslPath(`"${path.join(yield `"${this.leetCodeRootPath}"`, "bin", "leetcode")}"`)}`;
3634
}
37-
return `${this.leetCodeRootPathInWsl}`;
38-
}
39-
return `${this.leetCodeRootPath}`;
40-
}
41-
42-
public async getLeetCodeBinaryPath(): Promise<string> { // wrapped by ""
43-
return `"${path.join(await this.getLeetCodeRootPath(), "bin", "leetcode")}"`;
35+
return `"${path.join(yield `"${this.leetCodeRootPath}"`, "bin", "leetcode")}"`;
36+
});
4437
}
4538

4639
public async meetRequirements(): Promise<boolean> {
@@ -168,7 +161,7 @@ class LeetCodeExecutor implements Disposable {
168161

169162
public async getCompaniesAndTags(): Promise<{ companies: { [key: string]: string[] }, tags: { [key: string]: string[] } }> {
170163
// preprocess the plugin source
171-
const companiesTagsPath: string = path.join(await leetCodeExecutor.getLeetCodeRootPath(), "lib", "plugins", "company.js");
164+
const companiesTagsPath: string = path.join(await this.leetCodeRootPath, "lib", "plugins", "company.js");
172165
const companiesTagsSrc: string = (await fse.readFile(companiesTagsPath, "utf8")).replace(
173166
"module.exports = plugin",
174167
"module.exports = { COMPONIES, TAGS }",

0 commit comments

Comments
 (0)