Update shellPath.ts

This commit is contained in:
Patrick Erichsen 2025-06-16 18:55:43 -07:00
parent 64151c1242
commit 31f63c7691

View file

@ -1,10 +1,6 @@
import { execSync } from "child_process";
import { homedir } from "os";
/**
* Gets the PATH env var from the user's login shell on non-Windows platforms.
* Windows is not implemented primarily because it is not needed at the moment.
* @returns The enhanced PATH from the user's shell, or the current PATH if it cannot be determined
*/
export function getEnvPathFromUserShell(): string | undefined {
if (process.platform === "win32") {
console.warn(`${getEnvPathFromUserShell.name} not implemented for Windows`);
@ -16,7 +12,8 @@ export function getEnvPathFromUserShell(): string | undefined {
}
try {
const command = `${process.env.SHELL} -l -c 'echo $PATH'`;
// Source common profile files
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'`;
const stdout = execSync(command, {
encoding: "utf8",