* Creates a new tmux session if it doesn't exist
(sessionName: string)
| 169 | * Creates a new tmux session if it doesn't exist |
| 170 | */ |
| 171 | async function ensureSession(sessionName: string): Promise<void> { |
| 172 | const exists = await hasSession(sessionName) |
| 173 | if (!exists) { |
| 174 | const result = await execFileNoThrow(TMUX_COMMAND, [ |
| 175 | 'new-session', |
| 176 | '-d', |
| 177 | '-s', |
| 178 | sessionName, |
| 179 | ]) |
| 180 | if (result.code !== 0) { |
| 181 | throw new Error( |
| 182 | `Failed to create tmux session '${sessionName}': ${result.stderr || 'Unknown error'}`, |
| 183 | ) |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Gets the command to spawn a teammate. |
no test coverage detected