MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / runShellNodeProbe

Function runShellNodeProbe

desktop/runtime-host/client-environment.ts:44–70  ·  view source on GitHub ↗
(shell: string)

Source from the content-addressed store, hash-verified

42}
43
44function runShellNodeProbe(shell: string) {
45 return new Promise<string | null>((resolve) => {
46 const child = spawn(shell, ['-lc', 'command -v node'], {
47 stdio: ['ignore', 'pipe', 'ignore'],
48 })
49 let output = ''
50 const timeout = setTimeout(() => {
51 child.kill()
52 resolve(null)
53 }, 2_000)
54 child.stdout?.setEncoding('utf8')
55 child.stdout?.on('data', (chunk) => {
56 output += chunk
57 })
58 child.once('error', () => {
59 clearTimeout(timeout)
60 resolve(null)
61 })
62 child.once('exit', () => {
63 clearTimeout(timeout)
64 const candidate = output.trim().split('\n')[0]
65 resolve(
66 candidate && path.isAbsolute(candidate) && isExecutableFile(candidate) ? candidate : null,
67 )
68 })
69 })
70}
71
72async function discoverNodeFromShell() {
73 const shells = [

Callers 1

discoverNodeFromShellFunction · 0.85

Calls 4

spawnFunction · 0.85
resolveFunction · 0.85
isExecutableFileFunction · 0.70
killMethod · 0.65

Tested by

no test coverage detected