MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / captureUserPath

Function captureUserPath

apps/desktop/src/main/service.ts:43–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41let userPathCapture: Promise<string | undefined> | null = null;
42
43const captureUserPath = async (): Promise<string | undefined> => {
44 const shell = process.env.SHELL;
45 if (!shell) return process.env.PATH;
46 try {
47 const { stdout } = await execFileAsync(shell, ["-ilc", 'printf "%s" "$PATH"'], {
48 encoding: "utf8",
49 timeout: 5000,
50 });
51 const path = stdout.trim();
52 return path.length > 0 ? path : process.env.PATH;
53 } catch {
54 return process.env.PATH;
55 }
56};
57
58const memoizedUserPath = (): Promise<string | undefined> => {
59 userPathCapture ??= captureUserPath();

Callers 1

memoizedUserPathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected