| ... | @@ -26,15 +26,22 @@ const install = NodeChildProcess.spawnSync("vp i", { | ... | @@ -26,15 +26,22 @@ const install = NodeChildProcess.spawnSync("vp i", { |
| 26 | }); | 26 | }); |
| 27 | if (install.status !== 0) process.exit(install.status ?? 1); | 27 | if (install.status !== 0) process.exit(install.status ?? 1); |
| 28 | | 28 | |
| 29 | // In the main checkout itself, relinking would replace the real env files. | 29 | // Env files live as real files in the main checkout; worktrees only get |
| 30 | if (NodeFS.realpathSync(projectRoot) !== NodeFS.realpathSync(worktree)) { | 30 | // symlinks to them. Only a symlink is ever replaced, so a real env file is |
| 31 | for (const file of ENV_FILES) { | 31 | // never deleted, including when this runs in the main checkout itself. |
| 32 | const source = NodePath.join(projectRoot, file); | 32 | for (const file of ENV_FILES) { |
| 33 | if (!NodeFS.existsSync(source)) continue; | 33 | const source = NodePath.join(projectRoot, file); |
| 34 | const target = NodePath.join(worktree, file); | 34 | const sourceStat = NodeFS.lstatSync(source, { throwIfNoEntry: false }); |
| 35 | NodeFS.rmSync(target, { force: true }); | 35 | if (!sourceStat) continue; |
| 36 | NodeFS.symlinkSync(source, target); | 36 | if (!sourceStat.isFile()) { |
| | 37 | console.warn(`Skipping ${file}: ${source} is not a regular file.`); |
| | 38 | continue; |
| 37 | } | 39 | } |
| | 40 | const target = NodePath.join(worktree, file); |
| | 41 | const existing = NodeFS.lstatSync(target, { throwIfNoEntry: false }); |
| | 42 | if (existing && !existing.isSymbolicLink()) continue; |
| | 43 | if (existing) NodeFS.rmSync(target); |
| | 44 | NodeFS.symlinkSync(source, target); |
| 38 | } | 45 | } |
| 39 | | 46 | |
| 40 | const warm = NodeChildProcess.spawnSync( | 47 | const warm = NodeChildProcess.spawnSync( |