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