( remoteName?: string, )
| 3 | |
| 4 | const execAsync = promisify(exec); |
| 5 | export 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 | } |
no outgoing calls
no test coverage detected