claude-notification-plugin 1.0.10 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +116 -116
- package/bin/install.js +178 -178
- package/bin/uninstall.js +53 -53
- package/notifier/notifier.js +322 -322
- package/package.json +2 -2
package/bin/uninstall.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import os from 'os';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
|
|
7
|
-
const home = os.homedir();
|
|
8
|
-
const claudeDir = path.join(home, '.claude');
|
|
9
|
-
const configPath = path.join(claudeDir, 'notifier.config.json');
|
|
10
|
-
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
11
|
-
const statePath = path.join(claudeDir, '.notifier_state.json');
|
|
12
|
-
|
|
13
|
-
const HOOK_COMMAND = 'claude-notifier';
|
|
14
|
-
|
|
15
|
-
// Remove hooks from settings.json
|
|
16
|
-
if (fs.existsSync(settingsPath)) {
|
|
17
|
-
try {
|
|
18
|
-
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
|
|
19
|
-
|
|
20
|
-
if (settings.hooks) {
|
|
21
|
-
for (const event of Object.keys(settings.hooks)) {
|
|
22
|
-
settings.hooks[event] = settings.hooks[event].filter((matcher) =>
|
|
23
|
-
!matcher.hooks?.some((h) => h.command?.includes(HOOK_COMMAND)),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
if (settings.hooks[event].length === 0) {
|
|
27
|
-
delete settings.hooks[event];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (Object.keys(settings.hooks).length === 0) {
|
|
32
|
-
delete settings.hooks;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
37
|
-
} catch {
|
|
38
|
-
// ignore
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Remove config and state files
|
|
43
|
-
for (const file of [configPath, statePath]) {
|
|
44
|
-
if (fs.existsSync(file)) {
|
|
45
|
-
fs.unlinkSync(file);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
console.log('');
|
|
50
|
-
console.log('Claude Notification Plugin uninstalled.');
|
|
51
|
-
console.log('Hooks removed from settings.json');
|
|
52
|
-
console.log('Config files deleted.');
|
|
53
|
-
console.log('');
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import os from 'os';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
const home = os.homedir();
|
|
8
|
+
const claudeDir = path.join(home, '.claude');
|
|
9
|
+
const configPath = path.join(claudeDir, 'notifier.config.json');
|
|
10
|
+
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
11
|
+
const statePath = path.join(claudeDir, '.notifier_state.json');
|
|
12
|
+
|
|
13
|
+
const HOOK_COMMAND = 'claude-notifier';
|
|
14
|
+
|
|
15
|
+
// Remove hooks from settings.json
|
|
16
|
+
if (fs.existsSync(settingsPath)) {
|
|
17
|
+
try {
|
|
18
|
+
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
|
|
19
|
+
|
|
20
|
+
if (settings.hooks) {
|
|
21
|
+
for (const event of Object.keys(settings.hooks)) {
|
|
22
|
+
settings.hooks[event] = settings.hooks[event].filter((matcher) =>
|
|
23
|
+
!matcher.hooks?.some((h) => h.command?.includes(HOOK_COMMAND)),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (settings.hooks[event].length === 0) {
|
|
27
|
+
delete settings.hooks[event];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (Object.keys(settings.hooks).length === 0) {
|
|
32
|
+
delete settings.hooks;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
37
|
+
} catch {
|
|
38
|
+
// ignore
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Remove config and state files
|
|
43
|
+
for (const file of [configPath, statePath]) {
|
|
44
|
+
if (fs.existsSync(file)) {
|
|
45
|
+
fs.unlinkSync(file);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
console.log('');
|
|
50
|
+
console.log('Claude Notification Plugin uninstalled.');
|
|
51
|
+
console.log('Hooks removed from settings.json');
|
|
52
|
+
console.log('Config files deleted.');
|
|
53
|
+
console.log('');
|