(args: string[])
| 19 | |
| 20 | // Utility to run tmux commands |
| 21 | function tmux(args: string[]): Promise<string> { |
| 22 | return new Promise((resolve, reject) => { |
| 23 | const proc = spawn('tmux', args, { stdio: 'pipe' }) |
| 24 | let stdout = '' |
| 25 | let stderr = '' |
| 26 | |
| 27 | proc.stdout?.on('data', (data) => { |
| 28 | stdout += data.toString() |
| 29 | }) |
| 30 | |
| 31 | proc.stderr?.on('data', (data) => { |
| 32 | stderr += data.toString() |
| 33 | }) |
| 34 | |
| 35 | proc.on('close', (code) => { |
| 36 | if (code === 0) { |
| 37 | resolve(stdout) |
| 38 | } else { |
| 39 | reject(new Error(`tmux command failed: ${stderr}`)) |
| 40 | } |
| 41 | }) |
| 42 | }) |
| 43 | } |
| 44 | |
| 45 | // Capture pane content |
| 46 | async function capturePane(sessionName: string): Promise<string> { |
no test coverage detected