claude-hooks/scripts/npm-preuninstall.js
Ryan Malloy 9445e09c48 Add NPM distribution support with hybrid installation approach
Major changes:
- Add package.json with NPM packaging configuration
- Create Node.js CLI interface (bin/claude-hooks.js) with full command set
- Convert bash scripts to Python for better npm integration
- Add npm postinstall/preuninstall hooks for automatic setup
- Update bootstrap prompt to recommend NPM method with git fallback
- Enhance README with NPM-first documentation
- Maintain backward compatibility with existing git installation

Features:
- npm install -g claude-hooks for easy distribution
- claude-hooks init/status/test/backup/uninstall commands
- Automatic Python dependency installation
- Conflict detection and prevention
- Hybrid approach supporting both npm and git workflows

This resolves installation complexity while maintaining developer flexibility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-19 21:03:13 -06:00

33 lines
1.0 KiB
JavaScript

#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const os = require('os');
console.log('🗑️ Claude Hooks pre-uninstall cleanup...');
// Check if hooks are configured
const hooksConfig = path.join(os.homedir(), '.config', 'claude', 'hooks.json');
if (fs.existsSync(hooksConfig)) {
console.log('⚠️ Claude Hooks configuration detected');
console.log('');
console.log('IMPORTANT: This will remove the NPM package but leave hooks active!');
console.log('');
console.log('To properly uninstall:');
console.log('1. Run: claude-hooks uninstall');
console.log('2. Then run: npm uninstall -g claude-hooks');
console.log('');
console.log('Or to force removal of hooks configuration:');
console.log(`rm -f "${hooksConfig}"`);
console.log('');
// Give user a moment to see the message
setTimeout(() => {
console.log('Continuing with NPM package removal...');
}, 2000);
} else {
console.log('✓ No active hooks configuration found');
}
console.log('✓ Pre-uninstall check complete');