fix(install): guard link-mode conflicts#449
Conversation
devinoldenburg
left a comment
There was a problem hiding this comment.
Nice fix, this is definitely the right direction. One small thing before merging: prepareLinkDestination() uses existsSync(dest), which misses dangling symlinks because it follows the link. With a broken existing symlink, --link --force now skips cleanup and then fails with EEXIST when symlinkSync() runs. Could you switch that check to lstatSync() in a try/catch and treat only ENOENT as missing? A small regression test for a dangling symlink would be great too.
|
Addressed the dangling-symlink case and refreshed the branch on current Current head: Changes:
Validation:
I also checked the full suite after rebasing. |
1909f6d to
a32d1e2
Compare
Summary
--linkinstalls unless--forceis provided.--dry-runso destructive link-mode conflicts are visible before install.plugins/goal-mode/directory and for the explicit--forcereplacement path.Why
opencode-goal-mode-install --linkremoved existing destinations before creating symlinks. If a user already had a realplugins/goal-mode/directory under their OpenCode config, the installer could delete those files without requiring--force. Copy installs already treat conflicts conservatively, so link installs should do the same.Validation
plugins/goal-mode/keep.txt: install exited 0 and removed the file.--linkexits 1 and preserveskeep.txtwithout--force.--link --forcereplaces the directory with a symlink.npm test(26 pass)npm run lint(passes; existing warnings only in unrelated files)git diff --check