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

Commit06e33d2

Browse files
edvardchenjdneo
authored andcommitted
1 parent7ca9b8a commit06e33d2

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

‎src/leetCodeManager.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as vscode from "vscode";
77
import{leetCodeChannel}from"./leetCodeChannel";
88
import{leetCodeExecutor}from"./leetCodeExecutor";
99
import{UserStatus}from"./shared";
10+
import{createEnvOption}from"./utils/cpUtils";
1011
import{DialogType,promptForOpenOutputChannel}from"./utils/uiUtils";
1112
import*aswslfrom"./utils/wslUtils";
1213

@@ -42,7 +43,10 @@ class LeetCodeManager extends EventEmitter {
4243

4344
constchildProc:cp.ChildProcess=wsl.useWsl()
4445
?cp.spawn("wsl",["node",leetCodeBinaryPath,"user","-l"],{shell:true})
45-
:cp.spawn("node",[leetCodeBinaryPath,"user","-l"],{shell:true});
46+
:cp.spawn("node",[leetCodeBinaryPath,"user","-l"],{
47+
shell:true,
48+
env:createEnvOption(),
49+
});
4650

4751
childProc.stdout.on("data",(data:string|Buffer)=>{
4852
data=data.toString();

‎src/utils/cpUtils.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export async function executeCommand(command: string, args: string[], options: c
99
returnnewPromise((resolve:(res:string)=>void,reject:(e:Error)=>void):void=>{
1010
letresult:string="";
1111

12-
constchildProc:cp.ChildProcess=cp.spawn(command,args,options);
12+
constchildProc:cp.ChildProcess=cp.spawn(command,args,{ ...options,env:createEnvOption()});
1313

1414
childProc.stdout.on("data",(data:string|Buffer)=>{
1515
data=data.toString();
@@ -45,3 +45,18 @@ export async function executeCommandWithProgress(message: string, command: strin
4545
});
4646
returnresult;
4747
}
48+
49+
// clone process.env and add http proxy
50+
exportfunctioncreateEnvOption():{}{
51+
constproxy:string|undefined=getHttpAgent();
52+
if(proxy){
53+
constenv:any=Object.create(process.env);
54+
env.http_proxy=proxy;
55+
returnenv;
56+
}
57+
returnprocess.env;
58+
}
59+
60+
functiongetHttpAgent():string|undefined{
61+
returnvscode.workspace.getConfiguration("http").get<string>("proxy");
62+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp