Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7e4c10

Browse files
authored
bugfix: Correctly parse the WSL path to Windows path (LeetCode-OpenSource#510)
1 parent1a129db commitd7e4c10

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

‎src/leetCodeExecutor.ts

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

1515
classLeetCodeExecutorimplementsDisposable{
1616
privateleetCodeRootPath:string;
17-
privateleetCodeRootPathInWsl:string;
1817
privatenodeExecutable:string;
1918
privateconfigurationChangeListener: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,11 @@ class LeetCodeExecutor implements Disposable {
2927
},this);
3028
}
3129

32-
publicasyncgetLeetCodeRootPath():Promise<string>{// not wrapped by ""
30+
publicasyncgetLeetCodeBinaryPath():Promise<string>{
3331
if(wsl.useWsl()){
34-
if(!this.leetCodeRootPathInWsl){
35-
this.leetCodeRootPathInWsl=`${awaitwsl.toWslPath(this.leetCodeRootPath)}`;
36-
}
37-
return`${this.leetCodeRootPathInWsl}`;
32+
return`${awaitwsl.toWslPath(`"${path.join(this.leetCodeRootPath,"bin","leetcode")}"`)}`;
3833
}
39-
return`${this.leetCodeRootPath}`;
40-
}
41-
42-
publicasyncgetLeetCodeBinaryPath():Promise<string>{// wrapped by ""
43-
return`"${path.join(awaitthis.getLeetCodeRootPath(),"bin","leetcode")}"`;
34+
return`"${path.join(this.leetCodeRootPath,"bin","leetcode")}"`;
4435
}
4536

4637
publicasyncmeetRequirements():Promise<boolean>{
@@ -168,7 +159,7 @@ class LeetCodeExecutor implements Disposable {
168159

169160
publicasyncgetCompaniesAndTags():Promise<{companies:{[key:string]:string[]},tags:{[key:string]:string[]}}>{
170161
// preprocess the plugin source
171-
constcompaniesTagsPath:string=path.join(awaitleetCodeExecutor.getLeetCodeRootPath(),"lib","plugins","company.js");
162+
constcompaniesTagsPath:string=path.join(this.leetCodeRootPath,"lib","plugins","company.js");
172163
constcompaniesTagsSrc:string=(awaitfse.readFile(companiesTagsPath,"utf8")).replace(
173164
"module.exports = plugin",
174165
"module.exports = { COMPONIES, TAGS }",

‎src/utils/wslUtils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@ export async function toWslPath(path: string): Promise<string> {
1515
}
1616

1717
exportasyncfunctiontoWinPath(path:string):Promise<string>{
18-
return(awaitexecuteCommand("wsl",["wslpath","-w",`"${path}"`])).trim();
18+
if(path.startsWith("\\mnt\\")){
19+
return(awaitexecuteCommand("wsl",["wslpath","-w",`"${path.replace(/\\/g,"/").substr(0,6)}"`])).trim()+path.substr(7);
20+
}
21+
return(awaitexecuteCommand("wsl",["wslpath","-w","/"])).trim()+path;
1922
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp