-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreuninstall.mjs
More file actions
52 lines (45 loc) · 1.61 KB
/
preuninstall.mjs
File metadata and controls
52 lines (45 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { unlinkSync, existsSync, readFileSync, writeFileSync, readdirSync } from 'fs';
import { join, dirname, relative } from 'path';
import { homedir } from 'os';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const src = join(__dirname, 'claude');
const dest = join(homedir(), '.claude');
// Remove files that were installed from claude/
let removedCount = 0;
try {
const files = readdirSync(src, { recursive: true, withFileTypes: true })
.filter(e => e.isFile())
.map(e => relative(src, join(e.parentPath, e.name)));
for (const file of files) {
const filePath = join(dest, file);
try {
if (existsSync(filePath)) {
unlinkSync(filePath);
removedCount++;
}
} catch (err) {
// Silently ignore removal errors
}
}
} catch (err) {
// Silently ignore if claude/ dir doesn't exist
}
if (removedCount > 0) {
console.log(`\x1b[32m✓\x1b[0m Removed ${removedCount} Claude file(s) from ~/.claude/`);
}
// Remove linear permission from settings.json
const PERMISSION = 'Bash(linear:*)';
const settingsPath = join(dest, 'settings.json');
try {
if (existsSync(settingsPath)) {
const settings = JSON.parse(readFileSync(settingsPath, 'utf-8'));
if (settings.permissions?.allow?.includes(PERMISSION)) {
settings.permissions.allow = settings.permissions.allow.filter(p => p !== PERMISSION);
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
console.log(`\x1b[32m✓\x1b[0m Removed ${PERMISSION} from ~/.claude/settings.json`);
}
}
} catch (err) {
// Silently ignore settings errors
}