MCPcopy Create free account
hub / github.com/pingdotgg/t3code / readEnvironmentFromLoginShell

Function readEnvironmentFromLoginShell

packages/shared/src/shell.ts:305–328  ·  view source on GitHub ↗
(
  shell,
  names,
  execFile = NodeChildProcess.execFileSync,
)

Source from the content-addressed store, hash-verified

303) => Partial<Record<string, string>>;
304
305export const readEnvironmentFromLoginShell: ShellEnvironmentReader = (
306 shell,
307 names,
308 execFile = NodeChildProcess.execFileSync,
309) => {
310 if (names.length === 0) {
311 return {};
312 }
313
314 const output = execFile(shell, ["-ilc", buildEnvironmentCaptureCommand(names)], {
315 encoding: "utf8",
316 timeout: 5000,
317 });
318
319 const environment: Partial<Record<string, string>> = {};
320 for (const name of names) {
321 const value = extractEnvironmentValue(output, name);
322 if (value !== undefined) {
323 environment[name] = value;
324 }
325 }
326
327 return environment;
328};
329
330export type WindowsShellEnvironmentReader = (
331 names: ReadonlyArray<string>,

Callers 2

shell.test.tsFile · 0.90
readPathFromLoginShellFunction · 0.85

Calls 2

extractEnvironmentValueFunction · 0.85

Tested by

no test coverage detected