[ef-29] fix: npm uninstall leaves hooks in settings.json#26
Conversation
…to 0.0.1-beta.5 npm uninstall does not set INIT_CWD (unlike npm install), so the guard `!process.env.INIT_CWD || ...` caused the preuninstall script to exit immediately without removing hook entries from ~/.claude/settings.json. Fix: only skip when INIT_CWD is set AND equals cwd (true dev-context signal). When INIT_CWD is absent the script now proceeds with cleanup. Also updates the test that was asserting the broken early-exit behavior to instead verify hooks are removed in the npm-uninstall scenario. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe preuninstall script's development-context guard condition was inverted to exit only when Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Summary
npm uninstalldoes not setINIT_CWD(unlikenpm install). The preuninstall guard!process.env.INIT_CWD || ...treated a missingINIT_CWDas a dev-context signal and exited immediately — before removing any hooks from~/.claude/settings.json.scripts/preuninstall.mjstoprocess.env.INIT_CWD && process.env.INIT_CWD === process.cwd()— now only skips in true dev context (where INIT_CWD is explicitly set and matches cwd). When INIT_CWD is absent, cleanup proceeds normally.npm uninstall -gscenario).0.0.1-beta.5.Test plan
bun run test:run __tests__/scripts/preuninstall.test.ts— all 14 tests passnpm install -g failproofai && failproofai --install-policies && npm uninstall -g failproofaiand confirm hook entries are removed from~/.claude/settings.json🤖 Generated with Claude Code
Summary by CodeRabbit
Version: 0.0.1-beta.5