MCPcopy Index your code
hub / github.com/codeaashu/claude-code / createWrapperScript

Function createWrapperScript

src/utils/claudeInChrome/setup.ts:308–346  ·  view source on GitHub ↗

* Create a wrapper script in ~/.claude/chrome/ that invokes the given command. This is * necessary because Chrome's native host manifest "path" field cannot contain arguments. * * @param command - The full command to execute (e.g., "/path/to/claude --chrome-native-host") * @returns The path to t

(command: string)

Source from the content-addressed store, hash-verified

306 * @returns The path to the wrapper script
307 */
308async function createWrapperScript(command: string): Promise<string> {
309 const platform = getPlatform()
310 const chromeDir = join(getClaudeConfigHomeDir(), 'chrome')
311 const wrapperPath =
312 platform === 'windows'
313 ? join(chromeDir, 'chrome-native-host.bat')
314 : join(chromeDir, 'chrome-native-host')
315
316 const scriptContent =
317 platform === 'windows'
318 ? `@echo off
319REM Chrome native host wrapper script
320REM Generated by Claude Code - do not edit manually
321${command}
322`
323 : `#!/bin/sh
324# Chrome native host wrapper script
325# Generated by Claude Code - do not edit manually
326exec ${command}
327`
328
329 // Check if content matches to avoid unnecessary writes
330 const existingContent = await readFile(wrapperPath, 'utf-8').catch(() => null)
331 if (existingContent === scriptContent) {
332 return wrapperPath
333 }
334
335 await mkdir(chromeDir, { recursive: true })
336 await writeFile(wrapperPath, scriptContent)
337
338 if (platform !== 'windows') {
339 await chmod(wrapperPath, 0o755)
340 }
341
342 logForDebugging(
343 `[Claude in Chrome] Created Chrome native host wrapper script: ${wrapperPath}`,
344 )
345 return wrapperPath
346}
347
348/**
349 * Get cached value of whether Chrome extension is installed. Returns

Callers 1

setupClaudeInChromeFunction · 0.85

Calls 4

getPlatformFunction · 0.85
readFileFunction · 0.85
mkdirFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected