authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-10-04 19:18:48-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-10-04 19:18:48-07:00
logf8a308fbc90e89cd5f8d41b7fb169a03343bd9b5
treee150576638f7b648e230bc7d78dcaac5bbbfab5f
parent01f894e23e031ef32c25a15b518a94f20defea6f
signature Signed by PGP key B5690EEEBB952194

fix(dev): worktree setup never deletes a real env file (#15845)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

1 files changed, 15 insertions(+), 8 deletions(-)

scripts/setup-worktree.ts+15-8
......@@ -26,15 +26,22 @@ const install = NodeChildProcess.spawnSync("vp i", {
2626});
2727if (install.status !== 0) process.exit(install.status ?? 1);
2828
29// In the main checkout itself, relinking would replace the real env files.
30if (NodeFS.realpathSync(projectRoot) !== NodeFS.realpathSync(worktree)) {
31 for (const file of ENV_FILES) {
32 const source = NodePath.join(projectRoot, file);
33 if (!NodeFS.existsSync(source)) continue;
34 const target = NodePath.join(worktree, file);
35 NodeFS.rmSync(target, { force: true });
36 NodeFS.symlinkSync(source, target);
29// Env files live as real files in the main checkout; worktrees only get
30// symlinks to them. Only a symlink is ever replaced, so a real env file is
31// never deleted, including when this runs in the main checkout itself.
32for (const file of ENV_FILES) {
33 const source = NodePath.join(projectRoot, file);
34 const sourceStat = NodeFS.lstatSync(source, { throwIfNoEntry: false });
35 if (!sourceStat) continue;
36 if (!sourceStat.isFile()) {
37 console.warn(`Skipping ${file}: ${source} is not a regular file.`);
38 continue;
3739 }
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);
3845}
3946
4047const warm = NodeChildProcess.spawnSync(