(args: string[])
| 56 | |
| 57 | // Utility to run tmux commands |
| 58 | function tmux(args: string[]): Promise<string> { |
| 59 | return new Promise((resolve, reject) => { |
| 60 | const proc = spawn('tmux', args, { stdio: 'pipe' }) |
| 61 | let stdout = '' |
| 62 | let stderr = '' |
| 63 | |
| 64 | proc.stdout?.on('data', (data) => { |
| 65 | stdout += data.toString() |
| 66 | }) |
| 67 | |
| 68 | proc.stderr?.on('data', (data) => { |
| 69 | stderr += data.toString() |
| 70 | }) |
| 71 | |
| 72 | proc.on('close', (code) => { |
| 73 | if (code === 0) { |
| 74 | resolve(stdout) |
| 75 | } else { |
| 76 | reject(new Error(`tmux command failed: ${stderr}`)) |
| 77 | } |
| 78 | }) |
| 79 | }) |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Send input to the CLI using bracketed paste mode. |
no test coverage detected