Update shellPath.ts
This commit is contained in:
parent
64151c1242
commit
31f63c7691
1 changed files with 3 additions and 6 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue