@ghackk/multi-claude 1.0.20 → 1.0.21
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/bin/postinstall.js +40 -0
- package/package.json +4 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync } = require('child_process');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
|
|
7
|
+
if (os.platform() === 'win32') process.exit(0); // Windows npm bin is typically on PATH already
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
const npmBin = execSync('npm bin -g', { encoding: 'utf-8' }).trim();
|
|
11
|
+
if (!npmBin) process.exit(0);
|
|
12
|
+
|
|
13
|
+
// Check if already on PATH
|
|
14
|
+
const pathDirs = (process.env.PATH || '').split(':');
|
|
15
|
+
if (pathDirs.includes(npmBin)) process.exit(0);
|
|
16
|
+
|
|
17
|
+
const home = os.homedir();
|
|
18
|
+
const rcFiles = ['.bashrc', '.zshrc', '.profile'].map(f => path.join(home, f));
|
|
19
|
+
const exportLine = `export PATH="${npmBin}:$PATH"`;
|
|
20
|
+
|
|
21
|
+
let added = false;
|
|
22
|
+
for (const rc of rcFiles) {
|
|
23
|
+
if (!fs.existsSync(rc)) continue;
|
|
24
|
+
const content = fs.readFileSync(rc, 'utf-8');
|
|
25
|
+
if (content.includes(npmBin)) { added = true; break; }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!added) {
|
|
29
|
+
// Find first existing rc file to append to
|
|
30
|
+
for (const rc of rcFiles) {
|
|
31
|
+
if (!fs.existsSync(rc)) continue;
|
|
32
|
+
fs.appendFileSync(rc, `\n# npm global bin\n${exportLine}\n`);
|
|
33
|
+
console.log(` Added ${npmBin} to PATH in ${path.basename(rc)}`);
|
|
34
|
+
console.log(' Restart your terminal or run: source ~/' + path.basename(rc));
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} catch (_) {
|
|
39
|
+
// Silent fail — non-critical
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ghackk/multi-claude",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "Run multiple Claude CLI accounts with shared settings, plugins, marketplace sync, and backup/restore",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"postinstall": "node bin/postinstall.js"
|
|
7
|
+
},
|
|
5
8
|
"bin": {
|
|
6
9
|
"multi-claude": "bin/claude-multi.js"
|
|
7
10
|
},
|