claude-rpc 0.22.0 → 0.22.1
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/package.json +1 -1
- package/src/install.js +25 -9
- package/src/version.js +1 -1
package/package.json
CHANGED
package/src/install.js
CHANGED
|
@@ -635,18 +635,34 @@ function verifyHookPipe(exePath) {
|
|
|
635
635
|
// hooks to the now-persistent global bin exactly like a normal npm install.
|
|
636
636
|
// Best-effort + loud: a failed -g (perms, offline) returns false so the caller
|
|
637
637
|
// can stop with the manual command rather than wire a dead hook.
|
|
638
|
-
|
|
639
|
-
|
|
638
|
+
// Version of the GLOBALLY-installed claude-rpc, read straight off disk via
|
|
639
|
+
// `npm root -g` — NOT through PATH. While setup runs under `npx
|
|
640
|
+
// claude-rpc@latest`, npx prepends its own throwaway cache (the current
|
|
641
|
+
// VERSION) to PATH, so a bare `claude-rpc --version` resolves to npx's copy and
|
|
642
|
+
// always looks current — which made promoteNpxToGlobal skip the real upgrade
|
|
643
|
+
// and silently leave a stale older global behind (it printed ✓ but did
|
|
644
|
+
// nothing). Reading the global package.json sidesteps that PATH shadowing.
|
|
645
|
+
function globalInstalledVersion() {
|
|
640
646
|
try {
|
|
641
|
-
const
|
|
647
|
+
const r = spawnSync('npm', ['root', '-g'], {
|
|
642
648
|
encoding: 'utf8', timeout: 4000, windowsHide: true,
|
|
643
|
-
shell: process.platform === 'win32',
|
|
649
|
+
shell: process.platform === 'win32', // npm is npm.cmd on Windows
|
|
644
650
|
});
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
} catch {
|
|
651
|
+
const root = (r.stdout || '').trim();
|
|
652
|
+
if (!root) return null;
|
|
653
|
+
const pkg = JSON.parse(readFileSync(join(root, 'claude-rpc', 'package.json'), 'utf8'));
|
|
654
|
+
return typeof pkg.version === 'string' ? pkg.version : null;
|
|
655
|
+
} catch { return null; } // not installed / npm missing / unreadable
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function promoteNpxToGlobal() {
|
|
659
|
+
// Already promoted on a previous run AND current? Skip the redundant -g (also
|
|
660
|
+
// lets setup succeed when a correct global exists but `npm -g` would fail —
|
|
661
|
+
// perms/offline). Checks the on-disk global, immune to npx's PATH shadowing.
|
|
662
|
+
if (globalInstalledVersion() === VERSION) {
|
|
663
|
+
noop('global install current');
|
|
664
|
+
return true;
|
|
665
|
+
}
|
|
650
666
|
const r = spawnSync('npm', ['install', '-g', `claude-rpc@${VERSION}`], {
|
|
651
667
|
encoding: 'utf8',
|
|
652
668
|
shell: process.platform === 'win32', // npm is npm.cmd on Windows
|