(block: ScriptBlock, cwd: string)
| 201 | } |
| 202 | |
| 203 | async 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 | |
| 229 | export async function up(): Promise<void> { |
| 230 | try { |
no test coverage detected