fix(install): refuse to replace non-managed files or dirs during setup - #114
Open
56phil wants to merge 1 commit into
Open
fix(install): refuse to replace non-managed files or dirs during setup#11456phil wants to merge 1 commit into
56phil wants to merge 1 commit into
Conversation
linkSkills/linkDir/linkFile/linkHook previously did rmSync(dst,
{recursive:true}) before symlinking, silently destroying any pre-existing
file or directory at the destination. A user's own ~/.claude/hooks/
rtk-rewrite.sh (installed by RTK itself) or a user-authored skills dir
with a colliding name would be deleted without prompt or backup.
Add assertReplaceable(): the destination may only be replaced when it is
absent or already a symlink pointing back into this package. Anything
else throws with a clear message. The recursive rmSync is dropped in
favor of plain rmSync since the only removable case is now a single
managed symlink.
Closes danielvm-git#112
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
linkSkills/linkDir/linkFile/linkHookinscripts/lib/install-helpers.jspreviously didfs.rmSync(dst, { force: true, recursive: true })before symlinking — silently destroying any pre-existing file or directory at the destination. A user's own~/.claude/hooks/rtk-rewrite.sh(installed by RTK itself) or a user-authored skills dir with a colliding name would be deleted without prompt, backup, or any check.Change
Add
assertReplaceable(dst), called by all four link functions before removal:REPO_ROOT) → managed by bigpowers, safe to re-link.The
recursive: truermSync is dropped in favor of plainrmSync, since the only removable case is now a single managed symlink.Verification
bash scripts/test-install-helpers.sh→ ALL PASS (existing suite, no regressions).Closes #112.