( runtime: Runtime, sourceWorkspaceName: string, sourceWorkspaceId: string, targetWorkspaceName: string, projectName: string )
| 236 | * Silently succeeds if source file doesn't exist at either location. |
| 237 | */ |
| 238 | export async function copyPlanFile( |
| 239 | runtime: Runtime, |
| 240 | sourceWorkspaceName: string, |
| 241 | sourceWorkspaceId: string, |
| 242 | targetWorkspaceName: string, |
| 243 | projectName: string |
| 244 | ): Promise<void> { |
| 245 | const muxHome = runtime.getMuxHome(); |
| 246 | const sourcePath = getPlanFilePath(sourceWorkspaceName, projectName, muxHome); |
| 247 | // Legacy paths only used for non-Docker runtimes |
| 248 | const legacySourcePath = getLegacyPlanFilePath(sourceWorkspaceId); |
| 249 | const targetPath = getPlanFilePath(targetWorkspaceName, projectName, muxHome); |
| 250 | |
| 251 | // Prefer the new layout, but fall back to the legacy layout. |
| 252 | // |
| 253 | // Note: we intentionally use runtime file I/O instead of `cp` because: |
| 254 | // 1) bash doesn't expand ~ inside quotes |
| 255 | // 2) the target per-project plan directory may not exist yet |
| 256 | // 3) runtime.writeFile() already handles directory creation + tilde expansion |
| 257 | for (const candidatePath of [sourcePath, legacySourcePath]) { |
| 258 | try { |
| 259 | const content = await readFileString(runtime, candidatePath); |
| 260 | await writeFileString(runtime, targetPath, content); |
| 261 | return; |
| 262 | } catch { |
| 263 | // Try next candidate |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * Copy a plan file across runtimes (e.g., during fork where source/target may be |
nothing calls this directly
no test coverage detected