diff --git a/src/leetCodeManager.ts b/src/leetCodeManager.ts index 0456d2d1..1db3f5e2 100644 --- a/src/leetCodeManager.ts +++ b/src/leetCodeManager.ts @@ -7,6 +7,7 @@ import * as vscode from "vscode"; import { leetCodeChannel } from "./leetCodeChannel"; import { leetCodeExecutor } from "./leetCodeExecutor"; import { UserStatus } from "./shared"; +import { createEnvOption } from "./utils/cpUtils"; import { DialogType, promptForOpenOutputChannel } from "./utils/uiUtils"; import * as wsl from "./utils/wslUtils"; @@ -42,7 +43,10 @@ class LeetCodeManager extends EventEmitter { const childProc: cp.ChildProcess = wsl.useWsl() ? cp.spawn("wsl", ["node", leetCodeBinaryPath, "user", "-l"], { shell: true }) - : cp.spawn("node", [leetCodeBinaryPath, "user", "-l"], { shell: true }); + : cp.spawn("node", [leetCodeBinaryPath, "user", "-l"], { + shell: true, + env: createEnvOption(), + }); childProc.stdout.on("data", (data: string | Buffer) => { data = data.toString(); diff --git a/src/utils/cpUtils.ts b/src/utils/cpUtils.ts index eeb7c007..6e265e48 100644 --- a/src/utils/cpUtils.ts +++ b/src/utils/cpUtils.ts @@ -9,7 +9,7 @@ export async function executeCommand(command: string, args: string[], options: c return new Promise((resolve: (res: string) => void, reject: (e: Error) => void): void => { let result: string = ""; - const childProc: cp.ChildProcess = cp.spawn(command, args, options); + const childProc: cp.ChildProcess = cp.spawn(command, args, { ...options, env: createEnvOption() }); childProc.stdout.on("data", (data: string | Buffer) => { data = data.toString(); @@ -45,3 +45,18 @@ export async function executeCommandWithProgress(message: string, command: strin }); return result; } + +// clone process.env and add http proxy +export function createEnvOption(): {} { + const proxy: string | undefined = getHttpAgent(); + if (proxy) { + const env: any = Object.create(process.env); + env.http_proxy = proxy; + return env; + } + return process.env; +} + +function getHttpAgent(): string | undefined { + return vscode.workspace.getConfiguration("http").get("proxy"); +} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy