MCPcopy Create free account
hub / github.com/continuedev/continue / getEnvPathFromUserShell

Function getEnvPathFromUserShell

core/util/shellPath.ts:5–30  ·  view source on GitHub ↗
(
  remoteName?: string,
)

Source from the content-addressed store, hash-verified

3
4const execAsync = promisify(exec);
5export async function getEnvPathFromUserShell(
6 remoteName?: string,
7): Promise<string | undefined> {
8 const isWindowsHostWithWslRemote =
9 process.platform === "win32" && remoteName === "wsl";
10 if (process.platform === "win32" && !isWindowsHostWithWslRemote) {
11 return undefined;
12 }
13
14 if (!process.env.SHELL) {
15 return undefined;
16 }
17
18 try {
19 // Source common profile files
20 const command = `${process.env.SHELL} -l -c 'for f in ~/.zprofile ~/.zshrc ~/.bash_profile ~/.bashrc; do [ -f "$f" ] && source "$f" 2>/dev/null; done; echo $PATH'`;
21
22 const { stdout } = await execAsync(command, {
23 encoding: "utf8",
24 });
25
26 return stdout.trim();
27 } catch (error) {
28 return process.env.PATH; // Fallback to current PATH
29 }
30}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected