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

Function runBlock

src/cli/up.ts:203–227  ·  view source on GitHub ↗
(block: ScriptBlock, cwd: string)

Source from the content-addressed store, hash-verified

201}
202
203async function runBlock(block: ScriptBlock, cwd: string): Promise<number> {
204 const shellPath = resolveShellForLanguage(block.language)
205 const args = getShellArgs(shellPath, block.code)
206
207 logForDebugging(
208 `[code up] Running ${block.language || 'shell'} block from line ${block.startLine} with ${shellPath} in ${cwd}`,
209 )
210
211 return new Promise<number>(resolve => {
212 const child = spawn(shellPath, args, {
213 cwd,
214 env: process.env,
215 stdio: 'inherit',
216 })
217
218 child.once('error', error => {
219 writeToStderr(`code up failed to start ${shellPath}: ${error.message}\n`)
220 resolve(1)
221 })
222
223 child.once('close', code => {
224 resolve(code ?? 1)
225 })
226 })
227}
228
229export async function up(): Promise<void> {
230 try {

Callers 1

upFunction · 0.85

Calls 6

resolveShellForLanguageFunction · 0.85
getShellArgsFunction · 0.85
spawnFunction · 0.85
writeToStderrFunction · 0.85
logForDebuggingFunction · 0.50
resolveFunction · 0.50

Tested by

no test coverage detected