MCPcopy Create free account
hub / github.com/Noumena-Network/code / createWrapperScript

Function createWrapperScript

src/utils/claudeInChrome/setup.ts:311–349  ·  view source on GitHub ↗

* Create a wrapper script in config-home/chrome/ (typically ~/.ncode/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/ncode --chrome-native

(command: string)

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected