(args: string[])
| 49 | } |
| 50 | |
| 51 | function tmux(args: string[]): Promise<string> { |
| 52 | return new Promise((resolve, reject) => { |
| 53 | const proc = spawn('tmux', args, { stdio: 'pipe' }) |
| 54 | let stdout = '' |
| 55 | let stderr = '' |
| 56 | proc.stdout?.on('data', (d: Buffer) => { |
| 57 | stdout += d.toString() |
| 58 | }) |
| 59 | proc.stderr?.on('data', (d: Buffer) => { |
| 60 | stderr += d.toString() |
| 61 | }) |
| 62 | proc.on('close', (code) => { |
| 63 | if (code === 0) resolve(stdout) |
| 64 | else reject(new Error(`tmux failed (exit ${code}): ${stderr}`)) |
| 65 | }) |
| 66 | }) |
| 67 | } |
| 68 | |
| 69 | const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)) |
| 70 |
no test coverage detected