MCPcopy Create free account
hub / github.com/anomalyco/opencode / probe

Function probe

packages/desktop/src/main/shell-env.ts:36–62  ·  view source on GitHub ↗
(shell: string, mode: "-il" | "-l")

Source from the content-addressed store, hash-verified

34}
35
36function probe(shell: string, mode: "-il" | "-l"): Probe {
37 const out = spawnSync(shell, [mode, "-c", "env -0"], {
38 stdio: ["ignore", "pipe", "ignore"],
39 timeout: TIMEOUT,
40 windowsHide: true,
41 })
42
43 const err = out.error as NodeJS.ErrnoException | undefined
44 if (err) {
45 if (err.code === "ETIMEDOUT") return { type: "Timeout" }
46 console.log(`[server] Shell env probe failed for ${shell} ${mode}: ${err.message}`)
47 return { type: "Unavailable" }
48 }
49
50 if (out.status !== 0) {
51 console.log(`[server] Shell env probe exited with non-zero status for ${shell} ${mode}`)
52 return { type: "Unavailable" }
53 }
54
55 const env = parseShellEnv(out.stdout)
56 if (Object.keys(env).length === 0) {
57 console.log(`[server] Shell env probe returned empty env for ${shell} ${mode}`)
58 return { type: "Unavailable" }
59 }
60
61 return { type: "Loaded", value: env }
62}
63
64export function isNushell(shell: string) {
65 const name = basename(shell).toLowerCase()

Callers 1

loadShellEnvFunction · 0.85

Calls 2

parseShellEnvFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected