MCPcopy
hub / github.com/claude-code-best/claude-code / buildCliLaunch

Function buildCliLaunch

src/utils/cliLaunch.ts:100–134  ·  view source on GitHub ↗
(
  cliArgs: string[],
  opts?: { env?: NodeJS.ProcessEnv },
)

Source from the content-addressed store, hash-verified

98 * @param opts.env Override environment (defaults to process.env)
99 */
100export function buildCliLaunch(
101 cliArgs: string[],
102 opts?: { env?: NodeJS.ProcessEnv },
103): CliLaunchSpec {
104 const baseEnv = opts?.env ?? process.env
105
106 // In bundled mode the execPath IS the CLI binary — no script path needed.
107 // In script mode (dev / npm) we need the script path between runtime flags
108 // and CLI args so the runtime knows which file to execute.
109 const args: string[] =
110 isInBundledMode() || !SCRIPT_PATH
111 ? [...BOOTSTRAP_ARGS, ...cliArgs]
112 : [...BOOTSTRAP_ARGS, SCRIPT_PATH, ...cliArgs]
113
114 // Ensure Windows children can discover git-bash without shelling out
115 const env: NodeJS.ProcessEnv = { ...baseEnv }
116 if (IS_WINDOWS) {
117 if (
118 process.env.CLAUDE_CODE_GIT_BASH_PATH &&
119 !env.CLAUDE_CODE_GIT_BASH_PATH
120 ) {
121 env.CLAUDE_CODE_GIT_BASH_PATH = process.env.CLAUDE_CODE_GIT_BASH_PATH
122 }
123 if (process.env.SHELL && !env.SHELL) {
124 env.SHELL = process.env.SHELL
125 }
126 }
127
128 return {
129 execPath: EXEC_PATH,
130 args,
131 env,
132 windowsHide: IS_WINDOWS,
133 }
134}
135
136/**
137 * Spawn a child CLI process from a launch spec.

Callers 8

startDaemonFunction · 0.85
startDaemonFunction · 0.85
startMethod · 0.85
startMethod · 0.85
createLocalSSHSessionFunction · 0.85
reconnectFunction · 0.85
spawnWorkerFunction · 0.85

Calls 1

isInBundledModeFunction · 0.85

Tested by

no test coverage detected