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

Commitb319b62

Browse files
authored
fix bug for path containing whitespaces (LeetCode-OpenSource#35)
1 parentd928c06 commitb319b62

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

‎src/commands/show.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function showProblemInternal(channel: vscode.OutputChannel, id: string): P
4949

5050
constoutdir:string=awaitselectWorkspaceFolder();
5151
awaitfse.ensureDir(outdir);
52-
constresult:string=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"show",id,"-gx","-l",language,"-o",outdir]);
52+
constresult:string=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"show",id,"-gx","-l",language,"-o",`"${outdir}"`]);
5353
constreg:RegExp=/\*SourceCode:\s*(.*)/;
5454
constmatch:RegExpMatchArray|null=result.match(reg);
5555
if(match&&match.length>=2){

‎src/commands/submit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function submitSolution(channel: vscode.OutputChannel, uri?: vscode
1919
}
2020

2121
try{
22-
constresult:string=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"submit",filePath]);
22+
constresult:string=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"submit",`"${filePath}"`]);
2323
awaitshowResultFile(result);
2424
}catch(error){
2525
awaitpromptForOpenOutputChannel("Failed to submit the solution. Please open the output channel for details.",DialogType.error,channel);

‎src/commands/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export async function testSolution(channel: vscode.OutputChannel, uri?: vscode.U
4747
letresult:string|undefined;
4848
switch(choice.value){
4949
case":default":
50-
result=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"test",filePath]);
50+
result=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"test",`"${filePath}"`]);
5151
break;
5252
case":direct":
5353
consttestString:string|undefined=awaitvscode.window.showInputBox({
@@ -57,15 +57,15 @@ export async function testSolution(channel: vscode.OutputChannel, uri?: vscode.U
5757
ignoreFocusOut:true,
5858
});
5959
if(testString){
60-
result=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"test",filePath,"-t",`"${testString.replace(/"/g,"")}"`]);
60+
result=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"test",`"${filePath}"`,"-t",`"${testString.replace(/"/g,"")}"`]);
6161
}
6262
break;
6363
case":file":
6464
consttestFile:vscode.Uri[]|undefined=awaitshowFileSelectDialog();
6565
if(testFile&&testFile.length){
6666
constinput:string=awaitfse.readFile(testFile[0].fsPath,"utf-8");
6767
if(input.trim()){
68-
result=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"test",filePath,"-t",`"${input.replace(/"/g,"").replace(/\r?\n/g,"\\n")}"`]);
68+
result=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"test",`"${filePath}"`,"-t",`"${input.replace(/"/g,"").replace(/\r?\n/g,"\\n")}"`]);
6969
}else{
7070
vscode.window.showErrorMessage("The selected test file must not be empty.");
7171
}

‎src/leetCodeManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class LeetCodeManager extends EventEmitter implements ILeetCodeManager {
4343
try{
4444
constuserName:string|undefined=awaitnewPromise(async(resolve:(res:string|undefined)=>void,reject:(e:Error)=>void):Promise<void>=>{
4545
letresult:string="";
46-
constchildProc:cp.ChildProcess=cp.spawn("node",[leetCodeBinaryPath,"user","-l"]);
46+
constchildProc:cp.ChildProcess=cp.spawn("node",[leetCodeBinaryPath,"user","-l"],{shell:true});
4747
childProc.stdout.on("data",(data:string|Buffer)=>{
4848
data=data.toString();
4949
result=result.concat(data);

‎src/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import*aspathfrom"path";
44
import*asvscodefrom"vscode";
55

6-
exportconstleetCodeBinaryPath:string=path.join(__dirname,"..","..","node_modules","leetcode-cli","bin","leetcode");
6+
exportconstleetCodeBinaryPath:string=`"${path.join(__dirname,"..","..","node_modules","leetcode-cli","bin","leetcode")}"`;
77

88
exportinterfaceIQuickItemEx<T>extendsvscode.QuickPickItem{
99
value:T;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp