MCPcopy Create free account
hub / github.com/ConsortiumAI/Consortium / getCleanEnv

Function getCleanEnv

packages/consortium-cli/src/claude/sdk/utils.ts:18–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16 * Create a clean environment without local node_modules/.bin in PATH
17 */
18export function getCleanEnv(): NodeJS.ProcessEnv {
19 const env = { ...process.env }
20 const cwd = process.cwd()
21 const pathSep = process.platform === 'win32' ? ';' : ':'
22 const pathKey = process.platform === 'win32' ? 'Path' : 'PATH'
23 const actualPathKey = Object.keys(env).find(k => k.toLowerCase() === 'path') || pathKey
24
25 if (env[actualPathKey]) {
26 const cleanPath = env[actualPathKey]!
27 .split(pathSep)
28 .filter(p => {
29 const normalizedP = p.replace(/\\/g, '/').toLowerCase()
30 const normalizedCwd = cwd.replace(/\\/g, '/').toLowerCase()
31 return !normalizedP.startsWith(normalizedCwd)
32 })
33 .join(pathSep)
34 env[actualPathKey] = cleanPath
35 }
36
37 return env
38}
39
40/**
41 * Try to find globally installed Claude CLI

Callers 2

queryFunction · 0.90
findGlobalClaudePathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected