ソースを参照

Skip global install if codegraph command already exists

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Colby McHenry 5 ヶ月 前
コミット
f0ddfccf47
2 ファイル変更18 行追加8 行削除
  1. 1 1
      package.json
  2. 17 7
      src/installer/index.ts

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@colbymchenry/codegraph",
-  "version": "0.3.0",
+  "version": "0.3.1",
   "description": "Supercharge Claude Code with semantic code intelligence. 30% fewer tokens, 25% fewer tool calls, 100% local.",
   "main": "dist/index.js",
   "types": "dist/index.d.ts",

+ 17 - 7
src/installer/index.ts

@@ -26,16 +26,26 @@ export async function runInstaller(): Promise<void> {
   showBanner();
 
   try {
-    // Step 1: Install codegraph globally
-    console.log(chalk.dim('  Installing codegraph globally...'));
+    // Step 1: Check if codegraph is available (skip install if already there)
+    let codegraphAvailable = false;
     try {
-      execSync('npm install -g @colbymchenry/codegraph', { stdio: 'pipe' });
-      success('Installed codegraph command globally');
+      execSync('which codegraph', { stdio: 'pipe' });
+      codegraphAvailable = true;
     } catch {
-      // May fail if no permissions, but that's ok - npx still works
-      info('Could not install globally (try with sudo if needed)');
+      // Not installed globally yet
+    }
+
+    if (!codegraphAvailable) {
+      console.log(chalk.dim('  Installing codegraph globally...'));
+      try {
+        execSync('npm install -g @colbymchenry/codegraph', { stdio: 'pipe' });
+        success('Installed codegraph command globally');
+      } catch {
+        // May fail if no permissions, but that's ok - npx still works
+        info('Could not install globally (try with sudo if needed)');
+      }
+      console.log();
     }
-    console.log();
 
     // Step 2: Ask for installation location
     const location = await promptInstallLocation();